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
| @@ -162,6 +162,7 @@ set(CORPUS_OTHER | @@ -162,6 +162,7 @@ set(CORPUS_OTHER | ||
| 162 | 440599107.fuzz | 162 | 440599107.fuzz |
| 163 | 440747125.fuzz | 163 | 440747125.fuzz |
| 164 | 4720043549327360.fuzz | 164 | 4720043549327360.fuzz |
| 165 | + 4876793183272960.fuzz | ||
| 165 | 5109284021272576.fuzz | 166 | 5109284021272576.fuzz |
| 166 | 5344352869351424.fuzz | 167 | 5344352869351424.fuzz |
| 167 | 5828408539152384.fuzz | 168 | 5828408539152384.fuzz |
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,7 +11,7 @@ my $td = new TestDriver('fuzz'); | ||
| 11 | 11 | ||
| 12 | my $qpdf_corpus = $ENV{'QPDF_FUZZ_CORPUS'} || die "must set QPDF_FUZZ_CORPUS"; | 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 | my @fuzzers = ( | 16 | my @fuzzers = ( |
| 17 | ['ascii85' => 1], | 17 | ['ascii85' => 1], |
libqpdf/QPDF_objects.cc
| @@ -533,7 +533,7 @@ Objects::read_xref(qpdf_offset_t xref_offset, bool in_stream_recovery) | @@ -533,7 +533,7 @@ Objects::read_xref(qpdf_offset_t xref_offset, bool in_stream_recovery) | ||
| 533 | max_obj = std::max(max_obj, *(m->deleted_objects.rbegin())); | 533 | max_obj = std::max(max_obj, *(m->deleted_objects.rbegin())); |
| 534 | } | 534 | } |
| 535 | if (size < 1 || (size - 1) != max_obj) { | 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 | warn(damagedPDF( | 537 | warn(damagedPDF( |
| 538 | "", | 538 | "", |
| 539 | -1, | 539 | -1, |
qpdf/qtest/error-condition.test
| @@ -56,6 +56,7 @@ my @badfiles = ("not a PDF file", # 1 | @@ -56,6 +56,7 @@ my @badfiles = ("not a PDF file", # 1 | ||
| 56 | "space before xref", # 37 | 56 | "space before xref", # 37 |
| 57 | "startxref to space then eof", # 38 | 57 | "startxref to space then eof", # 38 |
| 58 | "stream lenth revocery overlapping", # 39 | 58 | "stream lenth revocery overlapping", # 39 |
| 59 | + "xref stream no entry for self", # 40 | ||
| 59 | ); | 60 | ); |
| 60 | 61 | ||
| 61 | $n_tests += @badfiles + 8; | 62 | $n_tests += @badfiles + 8; |
| @@ -66,7 +67,7 @@ $n_tests += @badfiles + 8; | @@ -66,7 +67,7 @@ $n_tests += @badfiles + 8; | ||
| 66 | # have error conditions that used to be fatal but are now considered | 67 | # have error conditions that used to be fatal but are now considered |
| 67 | # non-fatal. | 68 | # non-fatal. |
| 68 | my %badtest_overrides = (); | 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 | $badtest_overrides{$_} = 0; | 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 | WARNING: bad12.pdf (object 2 0, offset 128): expected endobj | 2 | WARNING: bad12.pdf (object 2 0, offset 128): expected endobj |
| 3 | /QTest is implicit | 3 | /QTest is implicit |
| 4 | /QTest is direct and has type null (2) | 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 | WARNING: bad12.pdf (object 2 0, offset 128): expected endobj | 2 | WARNING: bad12.pdf (object 2 0, offset 128): expected endobj |
| 3 | /QTest is implicit | 3 | /QTest is implicit |
| 4 | /QTest is direct and has type null (2) | 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