aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-08-11 18:36:57 +0200
committerJay Berkenbilt <ejb@ql.org>2012-08-11 18:36:57 +0200
commit3c4110184c02068e98849c7cbe11807ad7343721 (patch)
treecdd22b1e7337f30921c52f812b3bcf7b6554fcfd
parent29e9c34fe344616ec0e9e20bb2f055c7fb80a26d (diff)
downloadqpdf-3c4110184c02068e98849c7cbe11807ad7343721.tar.zst
Add specially crafted test cases for EOF error
This replaces a PDF from the wild that I didn't want to include in the test suite but used to verify the original fix.
-rw-r--r--TODO5
-rw-r--r--qpdf/qtest/qpdf.test10
-rw-r--r--qpdf/qtest/qpdf/eof-reading-token.out5
-rw-r--r--qpdf/qtest/qpdf/eof-reading-token.pdfbin0 -> 1632 bytes
-rw-r--r--qpdf/qtest/qpdf/eof-terminates-literal.out6
-rw-r--r--qpdf/qtest/qpdf/eof-terminates-literal.pdfbin0 -> 1632 bytes
6 files changed, 20 insertions, 6 deletions
diff --git a/TODO b/TODO
index 39a74de6..53f00a0e 100644
--- a/TODO
+++ b/TODO
@@ -5,11 +5,6 @@ Next
mention in latest release notes including that it was inadvertently
left out of the release notes for 3.0.0.
- * EOF while reading token causes a tokenizer error even when a valid
- token is ready. This can happen in an object stream if there is no
- newline or whitespace character at the end and the last token in
- the object stream is not an array or dictionary.
-
General
=======
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index da318491..fda92b30 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -149,7 +149,7 @@ $td->runtest("remove page we don't have",
$td->NORMALIZE_NEWLINES);
# ----------
$td->notify("--- Miscellaneous Tests ---");
-$n_tests += 45;
+$n_tests += 47;
$td->runtest("qpdf version",
{$td->COMMAND => "qpdf --version"},
@@ -374,6 +374,14 @@ $td->runtest("parse objects from string",
{$td->COMMAND => "test_driver 31 minimal.pdf"}, # file not used
{$td->FILE => "parse-object.out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
+$td->runtest("EOF terminating literal tokens",
+ {$td->COMMAND => "qpdf --check eof-terminates-literal.pdf"},
+ {$td->FILE => "eof-terminates-literal.out", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+$td->runtest("EOF reading token",
+ {$td->COMMAND => "qpdf --check eof-reading-token.pdf"},
+ {$td->FILE => "eof-reading-token.out", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
show_ntests();
# ----------
diff --git a/qpdf/qtest/qpdf/eof-reading-token.out b/qpdf/qtest/qpdf/eof-reading-token.out
new file mode 100644
index 00000000..58e5b09d
--- /dev/null
+++ b/qpdf/qtest/qpdf/eof-reading-token.out
@@ -0,0 +1,5 @@
+checking eof-reading-token.pdf
+PDF Version: 1.3
+File is not encrypted
+File is not linearized
+object stream 12 (file position 5): EOF while reading token
diff --git a/qpdf/qtest/qpdf/eof-reading-token.pdf b/qpdf/qtest/qpdf/eof-reading-token.pdf
new file mode 100644
index 00000000..080bb50b
--- /dev/null
+++ b/qpdf/qtest/qpdf/eof-reading-token.pdf
Binary files differ
diff --git a/qpdf/qtest/qpdf/eof-terminates-literal.out b/qpdf/qtest/qpdf/eof-terminates-literal.out
new file mode 100644
index 00000000..2feaefdd
--- /dev/null
+++ b/qpdf/qtest/qpdf/eof-terminates-literal.out
@@ -0,0 +1,6 @@
+checking eof-terminates-literal.pdf
+PDF Version: 1.3
+File is not encrypted
+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/eof-terminates-literal.pdf b/qpdf/qtest/qpdf/eof-terminates-literal.pdf
new file mode 100644
index 00000000..e695ec58
--- /dev/null
+++ b/qpdf/qtest/qpdf/eof-terminates-literal.pdf
Binary files differ