Commit 3c4110184c02068e98849c7cbe11807ad7343721

Authored by Jay Berkenbilt
1 parent 29e9c34f

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.
... ... @@ -5,11 +5,6 @@ Next
5 5 mention in latest release notes including that it was inadvertently
6 6 left out of the release notes for 3.0.0.
7 7  
8   - * EOF while reading token causes a tokenizer error even when a valid
9   - token is ready. This can happen in an object stream if there is no
10   - newline or whitespace character at the end and the last token in
11   - the object stream is not an array or dictionary.
12   -
13 8  
14 9 General
15 10 =======
... ...
qpdf/qtest/qpdf.test
... ... @@ -149,7 +149,7 @@ $td->runtest("remove page we don't have",
149 149 $td->NORMALIZE_NEWLINES);
150 150 # ----------
151 151 $td->notify("--- Miscellaneous Tests ---");
152   -$n_tests += 45;
  152 +$n_tests += 47;
153 153  
154 154 $td->runtest("qpdf version",
155 155 {$td->COMMAND => "qpdf --version"},
... ... @@ -374,6 +374,14 @@ $td->runtest("parse objects from string",
374 374 {$td->COMMAND => "test_driver 31 minimal.pdf"}, # file not used
375 375 {$td->FILE => "parse-object.out", $td->EXIT_STATUS => 0},
376 376 $td->NORMALIZE_NEWLINES);
  377 +$td->runtest("EOF terminating literal tokens",
  378 + {$td->COMMAND => "qpdf --check eof-terminates-literal.pdf"},
  379 + {$td->FILE => "eof-terminates-literal.out", $td->EXIT_STATUS => 0},
  380 + $td->NORMALIZE_NEWLINES);
  381 +$td->runtest("EOF reading token",
  382 + {$td->COMMAND => "qpdf --check eof-reading-token.pdf"},
  383 + {$td->FILE => "eof-reading-token.out", $td->EXIT_STATUS => 0},
  384 + $td->NORMALIZE_NEWLINES);
377 385  
378 386 show_ntests();
379 387 # ----------
... ...
qpdf/qtest/qpdf/eof-reading-token.out 0 → 100644
  1 +checking eof-reading-token.pdf
  2 +PDF Version: 1.3
  3 +File is not encrypted
  4 +File is not linearized
  5 +object stream 12 (file position 5): EOF while reading token
... ...
qpdf/qtest/qpdf/eof-reading-token.pdf 0 → 100644
No preview for this file type
qpdf/qtest/qpdf/eof-terminates-literal.out 0 → 100644
  1 +checking eof-terminates-literal.pdf
  2 +PDF Version: 1.3
  3 +File is not encrypted
  4 +File is not linearized
  5 +No syntax or stream encoding errors found; the file may still contain
  6 +errors that qpdf cannot detect
... ...
qpdf/qtest/qpdf/eof-terminates-literal.pdf 0 → 100644
No preview for this file type