summaryrefslogtreecommitdiffstats
path: root/qpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2021-11-04 17:11:48 +0100
committerJay Berkenbilt <ejb@ql.org>2021-11-04 17:29:42 +0100
commit4a648b9a00d2c4de37bf17165b20a1fc32956eee (patch)
treeb5e774eaf4374dd1973b8a2d7cd9a837d53812ab /qpdf
parent9b28933647f0a3ed535dd488c4526b75d1c10fc6 (diff)
downloadqpdf-4a648b9a00d2c4de37bf17165b20a1fc32956eee.tar.zst
Fix bug in merging resources /DR from foreign AcroForm (fixes #548)
When making resources indirect in from_dr, the code was using the wrong owning QPDF, forgetting that from_dr had already been copied using CopyForeignObject.
Diffstat (limited to 'qpdf')
-rw-r--r--qpdf/qtest/qpdf.test13
-rw-r--r--qpdf/qtest/qpdf/dr-with-indirect-item-out.pdf37
-rw-r--r--qpdf/qtest/qpdf/dr-with-indirect-item.pdf33
3 files changed, 81 insertions, 2 deletions
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index fc8c709f..af99bb2a 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -1025,7 +1025,7 @@ my @bug_tests = (
["335a", "ozz-fuzz-12152", 2],
["335b", "ozz-fuzz-14845", 2],
["fuzz-16214", "stream in object stream", 3, "--preserve-unreferenced"],
- # When adding to this list, consider adding to SEED_CORPUS_FILES
+ # When adding to this list, consider adding to CORPUS_FROM_TEST
# in fuzz/build.mk and updating the count in fuzz/qtest/fuzz.test.
);
$n_tests += scalar(@bug_tests);
@@ -3517,7 +3517,7 @@ for (my $n = 16; $n <= 19; ++$n)
show_ntests();
# ----------
$td->notify("--- Specific File Tests ---");
-$n_tests += 9;
+$n_tests += 11;
# Special PDF files that caused problems at some point
@@ -3556,6 +3556,15 @@ $td->runtest("pages points to page",
$td->runtest("check output",
{$td->FILE => "a.pdf"},
{$td->FILE => "pages-is-page-out.pdf"});
+$td->runtest("Acroform /DR with indirect subkey",
+ {$td->COMMAND =>
+ "qpdf --static-id --empty" .
+ " --pages dr-with-indirect-item.pdf -- a.pdf"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+$td->runtest("check output",
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "dr-with-indirect-item-out.pdf"});
show_ntests();
# ----------
diff --git a/qpdf/qtest/qpdf/dr-with-indirect-item-out.pdf b/qpdf/qtest/qpdf/dr-with-indirect-item-out.pdf
new file mode 100644
index 00000000..c6f5c88b
--- /dev/null
+++ b/qpdf/qtest/qpdf/dr-with-indirect-item-out.pdf
@@ -0,0 +1,37 @@
+%PDF-1.3
+%¿÷¢þ
+1 0 obj
+<< /AcroForm 2 0 R /Pages 3 0 R /Type /Catalog >>
+endobj
+2 0 obj
+<< /DR 4 0 R /Fields [ 5 0 R ] >>
+endobj
+3 0 obj
+<< /Count 1 /Kids [ 6 0 R ] /Type /Pages >>
+endobj
+4 0 obj
+<< /Font << /F 7 0 R >> >>
+endobj
+5 0 obj
+<< /DA (0 0 0 rg /Helv 11 Tf) /DV () /F 4 /FT /Tx /P 6 0 R /Rect [ 0 0 1 1 ] /Subtype /Widget /T () /TU () /Type /Annot /V () >>
+endobj
+6 0 obj
+<< /Annots [ 5 0 R ] /MediaBox [ 0 0 1 1 ] /Parent 3 0 R /Resources << /Font << >> >> /Type /Page >>
+endobj
+7 0 obj
+<< >>
+endobj
+xref
+0 8
+0000000000 65535 f
+0000000015 00000 n
+0000000080 00000 n
+0000000129 00000 n
+0000000188 00000 n
+0000000230 00000 n
+0000000374 00000 n
+0000000490 00000 n
+trailer << /Root 1 0 R /Size 8 /ID [<31415926535897932384626433832795><31415926535897932384626433832795>] >>
+startxref
+511
+%%EOF
diff --git a/qpdf/qtest/qpdf/dr-with-indirect-item.pdf b/qpdf/qtest/qpdf/dr-with-indirect-item.pdf
new file mode 100644
index 00000000..ebd4f7ee
--- /dev/null
+++ b/qpdf/qtest/qpdf/dr-with-indirect-item.pdf
@@ -0,0 +1,33 @@
+%PDF-1.4
+%¿÷¢þ
+1 0 obj
+<< /AcroForm << /DR 2 0 R /Fields [ 3 0 R ] >> /Pages 4 0 R /Type /Catalog >>
+endobj
+2 0 obj
+<< /Font 5 0 R >>
+endobj
+3 0 obj
+<< /DA (0 0 0 rg /Helv 11 Tf) /DV () /F 4 /FT /Tx /P 6 0 R /Rect [ 0 0 1 1 ] /Subtype /Widget /T () /TU () /Type /Annot /V () >>
+endobj
+4 0 obj
+<< /Count 1 /Kids [ 6 0 R ] /MediaBox [ 0 0 1 1 ] /Resources 2 0 R /Type /Pages >>
+endobj
+5 0 obj
+<< /F << >> >>
+endobj
+6 0 obj
+<< /Annots [ 3 0 R ] /MediaBox [ 0 0 1 1 ] /Parent 4 0 R /Resources 2 0 R /Type /Page >>
+endobj
+xref
+0 7
+0000000000 65535 f
+0000000015 00000 n
+0000000108 00000 n
+0000000141 00000 n
+0000000285 00000 n
+0000000383 00000 n
+0000000413 00000 n
+trailer << /Root 1 0 R /Size 7 /ID [<5e0a553555622a0516e9877ca55217a6><f50ce4731cef7b31118d5f69b0bed95c>] >>
+startxref
+517
+%%EOF