aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2017-08-12 01:53:56 +0200
committerJay Berkenbilt <ejb@ql.org>2017-08-12 01:53:56 +0200
commit8fe0b06cd879f503d0e5be63f706d3adda3b8203 (patch)
tree0c2d106e5d5f686761e78e06020a27c501aa754a /qpdf
parent0c99cf874b920f469bd6f7d65879b75a9c0af3fc (diff)
downloadqpdf-8fe0b06cd879f503d0e5be63f706d3adda3b8203.tar.zst
Pad encryption parameters that are too short (fixes #96)
Diffstat (limited to 'qpdf')
-rw-r--r--qpdf/qpdf.testcov1
-rw-r--r--qpdf/qtest/qpdf.test12
-rw-r--r--qpdf/qtest/qpdf/short-O-U.out20
-rw-r--r--qpdf/qtest/qpdf/short-O-U.pdf39
4 files changed, 71 insertions, 1 deletions
diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov
index c08ed721..0038aa34 100644
--- a/qpdf/qpdf.testcov
+++ b/qpdf/qpdf.testcov
@@ -293,3 +293,4 @@ QPDF ignore first space in xref entry 0
QPDF ignore first extra space in xref entry 0
QPDF ignore second extra space in xref entry 0
QPDF ignore length error xref entry 0
+QPDF_encryption pad short parameter 0
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index edd9f1ec..12fb5dd2 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -232,7 +232,7 @@ foreach my $d (@bug_tests)
show_ntests();
# ----------
$td->notify("--- Miscellaneous Tests ---");
-$n_tests += 87;
+$n_tests += 88;
$td->runtest("qpdf version",
{$td->COMMAND => "qpdf --version"},
@@ -676,6 +676,16 @@ $td->runtest("recoverable xref errors",
$td->EXIT_STATUS => 3},
$td->NORMALIZE_NEWLINES);
+# A file was emailed privately with issue 96. short-O-U.pdf was
+# created by copying encryption parameters from that file. It exhibits
+# the same behavior as the original file.
+$td->runtest("short /O or /U",
+ {$td->COMMAND =>
+ "qpdf --password=19723102477 --check short-O-U.pdf"},
+ {$td->FILE => "short-O-U.out",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+
show_ntests();
# ----------
$td->notify("--- Single Page ---");
diff --git a/qpdf/qtest/qpdf/short-O-U.out b/qpdf/qtest/qpdf/short-O-U.out
new file mode 100644
index 00000000..e0b19742
--- /dev/null
+++ b/qpdf/qtest/qpdf/short-O-U.out
@@ -0,0 +1,20 @@
+checking short-O-U.pdf
+PDF Version: 1.6
+R = 4
+P = -4
+User password = 19723102477
+extract for accessibility: allowed
+extract for any purpose: allowed
+print low resolution: allowed
+print high resolution: allowed
+modify document assembly: allowed
+modify forms: allowed
+modify annotations: allowed
+modify other: allowed
+modify anything: allowed
+stream encryption method: AESv2
+string encryption method: AESv2
+file encryption method: AESv2
+File is not linearized
+No syntax or stream encoding errors found; the file may still contain
+errors that qpdf cannot detect
diff --git a/qpdf/qtest/qpdf/short-O-U.pdf b/qpdf/qtest/qpdf/short-O-U.pdf
new file mode 100644
index 00000000..998a3f96
--- /dev/null
+++ b/qpdf/qtest/qpdf/short-O-U.pdf
@@ -0,0 +1,39 @@
+%PDF-1.6
+%
+1 0 obj
+<< /Pages 2 0 R /Type /Catalog >>
+endobj
+2 0 obj
+<< /Count 1 /Kids [ 3 0 R ] /Type /Pages >>
+endobj
+3 0 obj
+<< /Contents 4 0 R /MediaBox [ 0 0 612 792 ] /Parent 2 0 R /Resources << /Font << /F1 5 0 R >> /ProcSet 6 0 R >> /Type /Page >>
+endobj
+4 0 obj
+<< /Length 80 /Filter /FlateDecode >>
+stream
+tiUj,B\hlI-Z䠢D@B;dhR.rYb\{cBcC?{av<hendstream
+endobj
+5 0 obj
+<< /BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font >>
+endobj
+6 0 obj
+[ /PDF /Text ]
+endobj
+7 0 obj
+<< /CF << /StdCF << /AuthEvent /DocOpen /CFM /AESV2 /Length 16 >> >> /Filter /Standard /Length 128 /O <e9aa816e7e5861b853c9259303e9cbd1135453cc10e93f73a5c740de28649a75> /P -4 /R 4 /StmF /StdCF /StrF /StdCF /U <82f858c956fc27a1d051b09b9fb19b72> /V 4 >>
+endobj
+xref
+0 8
+0000000000 65535 f
+0000000015 00000 n
+0000000064 00000 n
+0000000123 00000 n
+0000000266 00000 n
+0000000416 00000 n
+0000000523 00000 n
+0000000553 00000 n
+trailer << /Root 1 0 R /Size 8 /ID [<35653732633166343063386438346132><e6a5593287c9d6485cf6706c8d97902c>] /Encrypt 7 0 R >>
+startxref
+820
+%%EOF