mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2025-07-18 23:09:49 +02:00
Fix trailer dictionary handling (Issue #58)
Fix generation number handling for object 0 (Issue #59)
This commit is contained in:
15
pdfio-file.c
15
pdfio-file.c
@ -1736,7 +1736,7 @@ load_xref(
|
||||
return (false);
|
||||
}
|
||||
|
||||
if ((generation = (int)strtol(ptr, &ptr, 10)) < 0 || generation > 65535)
|
||||
if ((generation = (int)strtol(ptr, &ptr, 10)) < 0 || (generation > 65535 && number != 0))
|
||||
{
|
||||
_pdfioFileError(pdf, "Bad xref table header '%s'.", line);
|
||||
return (false);
|
||||
@ -1979,9 +1979,20 @@ load_xref(
|
||||
while (_pdfioFileGets(pdf, line, sizeof(line)))
|
||||
{
|
||||
if (!strncmp(line, "trailer", 7) && (!line[7] || isspace(line[7] & 255)))
|
||||
{
|
||||
if (line[7])
|
||||
{
|
||||
// Probably the start of the trailer dictionary, rewind the file so
|
||||
// we can read it...
|
||||
_pdfioFileSeek(pdf, 7 - strlen(line), SEEK_CUR);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else if (!line[0])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sscanf(line, "%jd%jd", &number, &num_objects) != 2)
|
||||
{
|
||||
@ -2012,7 +2023,7 @@ load_xref(
|
||||
return (false);
|
||||
}
|
||||
|
||||
if ((generation = (int)strtol(ptr, &ptr, 10)) < 0 || generation > 65535)
|
||||
if ((generation = (int)strtol(ptr, &ptr, 10)) < 0 || (generation > 65535 && offset != 0))
|
||||
{
|
||||
_pdfioFileError(pdf, "Malformed xref table entry '%s'.", line);
|
||||
return (false);
|
||||
|
Reference in New Issue
Block a user