summaryrefslogtreecommitdiffstats
path: root/src/xplist.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2026-05-22 19:20:51 +0200
committerGravatar Nikias Bassen2026-05-22 19:20:51 +0200
commitba82092e43d4769dbc6f0557d58a243f93542486 (patch)
tree4054d7d4b701207f6a7def2799295557c5fdf68d /src/xplist.c
parent9711459dbed7d60bb00c7d2c052623e8489c88e1 (diff)
downloadlibplist-ba82092e43d4769dbc6f0557d58a243f93542486.tar.gz
libplist-ba82092e43d4769dbc6f0557d58a243f93542486.tar.bz2
common: validate PLIST_DATE values before Time64_T conversion
Avoid undefined behavior when serializing malformed PLIST_DATE values containing NaN, infinity, or values outside the Time64_T range. Add a shared helper for checked date conversion and use it across writer paths.
Diffstat (limited to 'src/xplist.c')
-rw-r--r--src/xplist.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/xplist.c b/src/xplist.c
index 8f5cb15..3157ab0 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -192,7 +192,10 @@ static plist_err_t node_to_xml(node_t node, bytearray_t **outbuf, uint32_t depth
192 tag = XPLIST_DATE; 192 tag = XPLIST_DATE;
193 tag_len = XPLIST_DATE_LEN; 193 tag_len = XPLIST_DATE_LEN;
194 { 194 {
195 Time64_T timev = (Time64_T)node_data->realval + MAC_EPOCH; 195 Time64_T timev;
196 if (plist_real_to_time64(node_data->realval, &timev) < 0) {
197 return PLIST_ERR_INVALID_ARG;
198 }
196 struct TM _btime; 199 struct TM _btime;
197 struct TM *btime = gmtime64_r(&timev, &_btime); 200 struct TM *btime = gmtime64_r(&timev, &_btime);
198 if (btime) { 201 if (btime) {