From 3c4110184c02068e98849c7cbe11807ad7343721 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 11 Aug 2012 12:36:57 -0400 Subject: [PATCH] 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. --- TODO | 5 ----- qpdf/qtest/qpdf.test | 10 +++++++++- qpdf/qtest/qpdf/eof-reading-token.out | 5 +++++ qpdf/qtest/qpdf/eof-reading-token.pdf | Bin 0 -> 1632 bytes qpdf/qtest/qpdf/eof-terminates-literal.out | 6 ++++++ qpdf/qtest/qpdf/eof-terminates-literal.pdf | Bin 0 -> 1632 bytes 6 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 qpdf/qtest/qpdf/eof-reading-token.out create mode 100644 qpdf/qtest/qpdf/eof-reading-token.pdf create mode 100644 qpdf/qtest/qpdf/eof-terminates-literal.out create mode 100644 qpdf/qtest/qpdf/eof-terminates-literal.pdf 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 0000000000000000000000000000000000000000..080bb50b96ae972897472b2b34c39037ff0b5ff1 GIT binary patch literal 1632 zcmbVMOK;Oa5Vq6u(2Bx|`v}R(91!Kr(mJ4LR0_oJ_mg{5J5X` zvBgEkqXvCEE+B4Xw0RJ4IqpOPObT`(b zE8HkWBXve~Cqg7O9d85~pLYe@{*%u95a%Ak=FVxs7%CaD0MA<5^|uNABAQ{9(=Z@E=q--IV_6JM%Qzf*N*73x{kFl{m&`hUX`{V>Nt&?MbR+ zwFtEZ!zeVHO~Y{;uEV{8XW9+VE?AyZa16_%N?Mt*wQ75mWy@2)=+KY;MW?C81 V15yzrqMKkz%sgsQ(^fW1>^Baot?2*& literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..e695ec58852d91ba910e13ed76ef65d630224950 GIT binary patch literal 1632 zcmbVMOK;Oa5Vq6u(2Bx|`v}R@nsSPq-<55f8hk}Gcpj0G0 z*kemRQXzJh4So~fT?>B(_zirYF2^De@eKI8Y{jP|&35$Y!CDgD!T=4rA8HSCfW4%r|oag5Cj&rf#8YWN7-lT^uS z5o!yDQD`=shT}F|hkFIjv>TpXuso;W7?xLe7mxo!qTKd5YOUrG4ww=SOxZHQlsA2w zZbGIw1s_$haXiNHT~XDqikiEDqob%3r*X_EIpr+cmuQ)yPF_ZP4()5S=N0wTv@)Ux Uq#{T}H^GvadDNn&t!$RqZ~k+w-~a#s literal 0 HcmV?d00001