diff --git a/CHANGES.md b/CHANGES.md index ac9b37a..4ce126b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ v1.4.0 - YYYY-MM-DD with `pdfioFileCreateFontObjFromBase` (Issue #84) - Fixed reading of PDF files whose trailer is missing a newline (Issue #80) - Fixed builds with some versions of VC++ (Issue #81) +- Fixed validation of date/time values (Issue #83) v1.3.2 - 2024-08-15 diff --git a/pdfio-value.c b/pdfio-value.c index 9fe960f..8bf95b9 100644 --- a/pdfio-value.c +++ b/pdfio-value.c @@ -755,6 +755,8 @@ get_date_time(const char *s) // I - PDF date/time value int offset; // Date offset + PDFIO_DEBUG("get_date_time(s=\"%s\")\n", s); + // Possible date value of the form: // // (D:YYYYMMDDhhmmssZ) @@ -772,10 +774,12 @@ get_date_time(const char *s) // I - PDF date/time value { if (s[i] == 'Z') { + // UTC... i ++; } else if (s[i] == '-' || s[i] == '+') { + // Timezone offset from UTC... if (isdigit(s[i + 1] & 255) && isdigit(s[i + 2] & 255) && s[i + 3] == '\'' && isdigit(s[i + 4] & 255) && isdigit(s[i + 5] & 255)) { i += 6; @@ -783,6 +787,11 @@ get_date_time(const char *s) // I - PDF date/time value i ++; } } + else if (!s[i]) + { + // Missing zone info, invalid date string... + return (0); + } } if (s[i])