Skip to content

Commit

Permalink
Fix validation of date/time values (Issue #83)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Dec 19, 2024
1 parent 5396755 commit b872df5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions pdfio-value.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -772,17 +774,24 @@ 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;
if (s[i] == '\'')
i ++;
}
}
else if (!s[i])
{
// Missing zone info, invalid date string...
return (0);
}
}

if (s[i])
Expand Down

0 comments on commit b872df5

Please sign in to comment.