2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 02:49:00 +00:00

Add additional sanity check during xref reconstruction

Check that xref table is not empty after recovery. Empty xref tables
disable other sanity checks.
This commit is contained in:
m-holger 2024-07-09 16:53:33 +01:00
parent 7445e0ac1e
commit 2e378d920d
2 changed files with 6 additions and 1 deletions

View File

@ -641,6 +641,11 @@ QPDF::reconstruct_xref(QPDFExc& e)
throw damagedPDF("", 0, "unable to find trailer dictionary while recovering damaged file");
}
if (m->xref_table.empty()) {
// We cannot check for an empty xref table in parse because empty tables are valid when
// creating QPDF objects from JSON.
throw damagedPDF("", 0, "unable to find objects while recovering damaged file");
}
// We could iterate through the objects looking for streams and try to find objects inside of
// them, but it's probably not worth the trouble. Acrobat can't recover files with any errors

View File

@ -4,4 +4,4 @@ WARNING: issue-147.pdf: can't find startxref
WARNING: issue-147.pdf: Attempting to reconstruct cross-reference table
WARNING: issue-147.pdf (trailer, offset 9): expected dictionary key but found non-name object; inserting key /QPDFFake1
WARNING: issue-147.pdf: ignoring object with impossibly large id 62
qpdf: issue-147.pdf: unable to find /Root dictionary
qpdf: issue-147.pdf: unable to find objects while recovering damaged file