Commit 133e53080e3ccdafeed5c5f79d115f2e3184e35c
1 parent
db575083
Improve handling of xref stream anomalies and update tests.
Fix bug in #1595
Showing
10 changed files
with
23 additions
and
5 deletions
fuzz/CMakeLists.txt
fuzz/qpdf_extra/4876793183272960.fuzz
0 → 100644
No preview for this file type
fuzz/qtest/fuzz.test
| ... | ... | @@ -11,7 +11,7 @@ my $td = new TestDriver('fuzz'); |
| 11 | 11 | |
| 12 | 12 | my $qpdf_corpus = $ENV{'QPDF_FUZZ_CORPUS'} || die "must set QPDF_FUZZ_CORPUS"; |
| 13 | 13 | |
| 14 | -my $n_qpdf_files = 105; # increment when adding new files | |
| 14 | +my $n_qpdf_files = 106; # increment when adding new files | |
| 15 | 15 | |
| 16 | 16 | my @fuzzers = ( |
| 17 | 17 | ['ascii85' => 1], | ... | ... |
libqpdf/QPDF_objects.cc
| ... | ... | @@ -533,7 +533,7 @@ Objects::read_xref(qpdf_offset_t xref_offset, bool in_stream_recovery) |
| 533 | 533 | max_obj = std::max(max_obj, *(m->deleted_objects.rbegin())); |
| 534 | 534 | } |
| 535 | 535 | if (size < 1 || (size - 1) != max_obj) { |
| 536 | - if ((size - 2) == max_obj) { //&& qpdf.getObject(max_obj, 0).isStreamOfType("/XRef")) { | |
| 536 | + if (size == (max_obj + 2) && qpdf.getObject(max_obj +1, 0).isStreamOfType("/XRef")) { | |
| 537 | 537 | warn(damagedPDF( |
| 538 | 538 | "", |
| 539 | 539 | -1, | ... | ... |
qpdf/qtest/error-condition.test
| ... | ... | @@ -56,6 +56,7 @@ my @badfiles = ("not a PDF file", # 1 |
| 56 | 56 | "space before xref", # 37 |
| 57 | 57 | "startxref to space then eof", # 38 |
| 58 | 58 | "stream lenth revocery overlapping", # 39 |
| 59 | + "xref stream no entry for self", # 40 | |
| 59 | 60 | ); |
| 60 | 61 | |
| 61 | 62 | $n_tests += @badfiles + 8; |
| ... | ... | @@ -66,7 +67,7 @@ $n_tests += @badfiles + 8; |
| 66 | 67 | # have error conditions that used to be fatal but are now considered |
| 67 | 68 | # non-fatal. |
| 68 | 69 | my %badtest_overrides = (); |
| 69 | -for(6, 12..15, 17, 18..32, 34..37, 39) | |
| 70 | +for(6, 12..15, 17, 18..32, 34..37, 39, 40) | |
| 70 | 71 | { |
| 71 | 72 | $badtest_overrides{$_} = 0; |
| 72 | 73 | } | ... | ... |
qpdf/qtest/qpdf/bad12-recover.out
| 1 | -WARNING: bad12.pdf: xref entry for the xref stream itself is missing - a common error handled correctly by qpdf and most other applications | |
| 1 | +WARNING: bad12.pdf: reported number of objects (9) is not one plus the highest object number (7) | |
| 2 | 2 | WARNING: bad12.pdf (object 2 0, offset 128): expected endobj |
| 3 | 3 | /QTest is implicit |
| 4 | 4 | /QTest is direct and has type null (2) | ... | ... |
qpdf/qtest/qpdf/bad12.out
| 1 | -WARNING: bad12.pdf: xref entry for the xref stream itself is missing - a common error handled correctly by qpdf and most other applications | |
| 1 | +WARNING: bad12.pdf: reported number of objects (9) is not one plus the highest object number (7) | |
| 2 | 2 | WARNING: bad12.pdf (object 2 0, offset 128): expected endobj |
| 3 | 3 | /QTest is implicit |
| 4 | 4 | /QTest is direct and has type null (2) | ... | ... |
qpdf/qtest/qpdf/bad40-recover.out
0 → 100644
| 1 | +WARNING: bad40.pdf: xref entry for the xref stream itself is missing - a common error handled correctly by qpdf and most other applications | |
| 2 | +WARNING: bad40.pdf object stream 1 (object 1 0, offset 0): object stream claims to contain itself | |
| 3 | +/QTest is implicit | |
| 4 | +/QTest is direct and has type null (2) | |
| 5 | +/QTest is null | |
| 6 | +unparse: null | |
| 7 | +unparseResolved: null | |
| 8 | +test 1 done | ... | ... |
qpdf/qtest/qpdf/bad40.out
0 → 100644
| 1 | +WARNING: bad40.pdf: xref entry for the xref stream itself is missing - a common error handled correctly by qpdf and most other applications | |
| 2 | +WARNING: bad40.pdf object stream 1 (object 1 0, offset 0): object stream claims to contain itself | |
| 3 | +/QTest is implicit | |
| 4 | +/QTest is direct and has type null (2) | |
| 5 | +/QTest is null | |
| 6 | +unparse: null | |
| 7 | +unparseResolved: null | |
| 8 | +test 0 done | ... | ... |
qpdf/qtest/qpdf/bad40.pdf
0 → 100644
No preview for this file type