Fix validation of date/time values (Issue #83)

This commit is contained in:
Michael R Sweet 2024-12-19 15:41:43 -05:00
parent 53967552df
commit b872df5a1e
No known key found for this signature in database
GPG Key ID: BE67C75EC81F3244
2 changed files with 10 additions and 0 deletions

View File

@ -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

View File

@ -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])