diff options
author | Jay Berkenbilt <ejb@ql.org> | 2017-07-26 11:03:38 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2017-07-26 12:24:07 +0200 |
commit | 701b518d5c56a1449825a3a37a716c58e05e1c3e (patch) | |
tree | bb4891231a8150bf3a2ccb56bca298df433210a0 /qpdf/qtest | |
parent | afe0242b263a9e1a8d51dd81e42ab6de2e5127eb (diff) | |
download | qpdf-701b518d5c56a1449825a3a37a716c58e05e1c3e.tar.zst |
Detect recursion loops resolving objects (fixes #51)
During parsing of an object, sometimes parts of the object have to be
resolved. An example is stream lengths. If such an object directly or
indirectly points to the object being parsed, it can cause an infinite
loop. Guard against all cases of re-entrant resolution of objects.
Diffstat (limited to 'qpdf/qtest')
-rw-r--r-- | qpdf/qtest/qpdf.test | 3 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/issue-51.out | 6 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/issue-51.pdf | 22 |
3 files changed, 30 insertions, 1 deletions
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index c45215fa..c0207019 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -206,7 +206,7 @@ $td->runtest("remove page we don't have", show_ntests(); # ---------- $td->notify("--- Miscellaneous Tests ---"); -$n_tests += 81; +$n_tests += 82; $td->runtest("qpdf version", {$td->COMMAND => "qpdf --version"}, @@ -220,6 +220,7 @@ $td->runtest("C API: qpdf version", # Files to reproduce various bugs foreach my $d ( + ["51", "resolve loop"], ["99", "object 0"], ["99b", "object 0"], ["100","xref reconstruction loop"], diff --git a/qpdf/qtest/qpdf/issue-51.out b/qpdf/qtest/qpdf/issue-51.out new file mode 100644 index 00000000..7f2192f6 --- /dev/null +++ b/qpdf/qtest/qpdf/issue-51.out @@ -0,0 +1,6 @@ +WARNING: issue-51.pdf: reported number of objects (0) inconsistent with actual number of objects (9) +WARNING: issue-51.pdf (object 7 0, file position 553): expected endobj +WARNING: issue-51.pdf (object 1 0, file position 359): expected endobj +WARNING: issue-51.pdf (file position 70): loop detected resolving object 2 0 +WARNING: issue-51.pdf (object 2 0, file position 71): attempting to recover stream length +issue-51.pdf (object 2 0, file position 71): unable to recover stream data diff --git a/qpdf/qtest/qpdf/issue-51.pdf b/qpdf/qtest/qpdf/issue-51.pdf new file mode 100644 index 00000000..2dafce1a --- /dev/null +++ b/qpdf/qtest/qpdf/issue-51.pdf @@ -0,0 +1,22 @@ +%PDF-100000000000002 0 obj +<</Length 2 0 R/000000/00000000000>> +stream +000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 0 obj +<</0000000000000000 0 0 R/000000000 0 0 R/00000000[00000000000]/00000<</0/00000000000000000000000000000000>>/00000000 2 0 R>>000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007 0 obj +<</0000/0000000/00000 0 0 R +/0000000000[1 0 R 0000 null null 0] +/0000(00000) +>>0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000xref +0 9 +0000000000 00000 f +0000000200 00000 n +0000000009 00000 n +0000000000 00000 n +0000000000 00000 n +0000000000 00000 n +0000000000 00000 n +0000000400 00000 n +0000000000 00000 n +trailer<</Size 0/Root 7 0 R>>startxref +740 +%%EOF
\ No newline at end of file |