2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00

Explicitly check root dictionary type

Very badly corrupted files may not have a retrievable root dictionary.
Handle that as a special case so that a more helpful error message can
be provided.
This commit is contained in:
Jay Berkenbilt 2017-07-28 18:02:39 -04:00
parent ede1255a82
commit a94a729fee
7 changed files with 14 additions and 7 deletions

View File

@ -2028,7 +2028,14 @@ QPDF::getTrailer()
QPDFObjectHandle QPDFObjectHandle
QPDF::getRoot() QPDF::getRoot()
{ {
return this->trailer.getKey("/Root"); QPDFObjectHandle root = this->trailer.getKey("/Root");
if (! root.isDictionary())
{
throw QPDFExc(qpdf_e_damaged_pdf, file->getName(),
"", file->getLastOffset(),
"unable to find /Root dictionary");
}
return root;
} }
void void

View File

@ -1,2 +1,2 @@
WARNING: bad35.pdf (object 1 0, file position 521): supposed object stream 1 has wrong type WARNING: bad35.pdf (object 1 0, file position 521): supposed object stream 1 has wrong type
operation for Dictionary object attempted on object of wrong type bad35.pdf (file position 521): unable to find /Root dictionary

View File

@ -1,2 +1,2 @@
WARNING: bad35.pdf (object 1 0, file position 521): supposed object stream 1 has wrong type WARNING: bad35.pdf (object 1 0, file position 521): supposed object stream 1 has wrong type
operation for Dictionary object attempted on object of wrong type bad35.pdf (file position 521): unable to find /Root dictionary

View File

@ -12,4 +12,4 @@ WARNING: issue-100.pdf (object 5 0, file position 418): /Length key in stream di
WARNING: issue-100.pdf (object 5 0, file position 489): attempting to recover stream length WARNING: issue-100.pdf (object 5 0, file position 489): attempting to recover stream length
WARNING: issue-100.pdf (trailer, file position 953): expected dictionary key but found non-name object; inserting key /QPDFFake1 WARNING: issue-100.pdf (trailer, file position 953): expected dictionary key but found non-name object; inserting key /QPDFFake1
WARNING: issue-100.pdf (trailer, file position 953): dictionary ended prematurely; using null as value for last key WARNING: issue-100.pdf (trailer, file position 953): dictionary ended prematurely; using null as value for last key
operation for Dictionary object attempted on object of wrong type issue-100.pdf (file position 1138): unable to find /Root dictionary

View File

@ -1,3 +1,3 @@
WARNING: issue-118.pdf (file position 732): loop detected resolving object 2 0 WARNING: issue-118.pdf (file position 732): loop detected resolving object 2 0
WARNING: issue-118.pdf (xref stream: object 8 0, file position 732): supposed object stream 2 is not a stream WARNING: issue-118.pdf (xref stream: object 8 0, file position 732): supposed object stream 2 is not a stream
operation for Dictionary object attempted on object of wrong type issue-118.pdf (file position 732): unable to find /Root dictionary

View File

@ -1,4 +1,4 @@
WARNING: issue-99.pdf: file is damaged WARNING: issue-99.pdf: file is damaged
WARNING: issue-99.pdf (file position 3526): xref not found WARNING: issue-99.pdf (file position 3526): xref not found
WARNING: issue-99.pdf: Attempting to reconstruct cross-reference table WARNING: issue-99.pdf: Attempting to reconstruct cross-reference table
operation for Dictionary object attempted on object of wrong type issue-99.pdf (file position 4793): unable to find /Root dictionary

View File

@ -2,4 +2,4 @@ WARNING: issue-99b.pdf: file is damaged
WARNING: issue-99b.pdf (object 1 0, file position 9): object with ID 0 WARNING: issue-99b.pdf (object 1 0, file position 9): object with ID 0
WARNING: issue-99b.pdf: Attempting to reconstruct cross-reference table WARNING: issue-99b.pdf: Attempting to reconstruct cross-reference table
WARNING: issue-99b.pdf: object 1 0 not found in file after regenerating cross reference table WARNING: issue-99b.pdf: object 1 0 not found in file after regenerating cross reference table
operation for Dictionary object attempted on object of wrong type issue-99b.pdf (file position 757): unable to find /Root dictionary