Skip to content

Commit

Permalink
Fix possible infinite loop case when looking for a trailer.
Browse files Browse the repository at this point in the history
Thanks to chibataiki for reporting and isolating this!
  • Loading branch information
enferex committed Apr 19, 2021
1 parent 8d07e05 commit 7e35d18
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ ZanderChang: Reported and identified bad code in kid page loading.
yifengchen-cc: Reported a header parsing bug.

kinzhong: Reported and isolated a xref scanning bug.

chibataiki: Reported and isolated an infinite loop in the trailer search.
3 changes: 2 additions & 1 deletion pdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,8 @@ static void get_xref_linear_skipped(FILE *fp, xref_t *xref)
/* If we found 'trailer' look backwards for 'xref' */
ch = 0;
while (SAFE_F(fp, ((ch = fgetc(fp)) != 'x')))
fseek(fp, -2, SEEK_CUR);
if (fseek(fp, -2, SEEK_CUR) == -1)
FAIL("Failed to locate an xref. This might be a corrupt PDF.\n");

if (ch == 'x')
{
Expand Down

0 comments on commit 7e35d18

Please sign in to comment.