Commit a1fe40a4f03029a8ce999f6d8e162893e01c902d

Authored by Jay Berkenbilt
Committed by GitHub
2 parents 0bb1458f 85107f39

Merge pull request #1169 from m-holger/xref_test

Add bad xref table test
qpdf/qtest/qpdf/bad-xref.pdf 0 → 100644
  1 +%PDF-1.3
  2 +1 0 obj
  3 +<<
  4 + /Type /Catalog
  5 + /Pages 2 0 R
  6 +>>
  7 +endobj
  8 +
  9 +2 0 obj
  10 +<<
  11 + /Type /Pages
  12 + /Kids [
  13 + 3 0 R
  14 + ]
  15 + /Count 1
  16 +>>
  17 +endobj
  18 +
  19 +3 0 obj
  20 +<<
  21 + /Type /Page
  22 + /Parent 2 0 R
  23 + /MediaBox [0 0 612 792]
  24 + /Contents 4 0 R
  25 + /Resources <<
  26 + /ProcSet 5 0 R
  27 + /Font <<
  28 + /F1 6 0 R
  29 + >>
  30 + >>
  31 +>>
  32 +endobj
  33 +
  34 +4 0 obj
  35 +<<
  36 + /Length 44
  37 +>>
  38 +stream
  39 +BT
  40 + /F1 24 Tf
  41 + 72 720 Td
  42 + (Potato) Tj
  43 +ET
  44 +endstream
  45 +endobj
  46 +
  47 +5 0 obj
  48 +[
  49 + /PDF
  50 + /Text
  51 +]
  52 +endobj
  53 +
  54 +6 0 obj
  55 +<<
  56 + /Type /Font
  57 + /Subtype /Type1
  58 + /Name /F1
  59 + /BaseFont /Helvetica
  60 + /Encoding /WinAnsiEncoding
  61 +>>
  62 +endobj
  63 +
  64 +xref
  65 +0 7
  66 +0000000000 65535 f don't panick
  67 +0000000009 00000 n life is too short
  68 +0000000063 00000 n
  69 +
  70 +
  71 +
  72 +
  73 +
  74 +0000000135 00000 n
  75 +0000000307 00000 n
  76 +0000000403 00000 n
  77 +
  78 +
  79 +
  80 +
  81 +
  82 +
  83 +
  84 +
  85 +
  86 +
  87 +
  88 +
  89 +
  90 +
  91 +
  92 +
  93 +
  94 +
  95 +
  96 +
  97 +0000000438 00000 n
  98 +trailer <<
  99 + /Size 7
  100 + /Root 1 0 R
  101 +>>
  102 +startxref
  103 +556
  104 +%%EOF
qpdf/qtest/xref-errors.test
@@ -14,7 +14,7 @@ cleanup(); @@ -14,7 +14,7 @@ cleanup();
14 14
15 my $td = new TestDriver('xref-errors'); 15 my $td = new TestDriver('xref-errors');
16 16
17 -my $n_tests = 6; 17 +my $n_tests = 7;
18 18
19 # Handle file with invalid xref table and object 0 as a regular object 19 # Handle file with invalid xref table and object 0 as a regular object
20 # (bug 3159950). 20 # (bug 3159950).
@@ -62,5 +62,10 @@ $td-&gt;runtest(&quot;out of range in deleted object&quot;, @@ -62,5 +62,10 @@ $td-&gt;runtest(&quot;out of range in deleted object&quot;,
62 {$td->FILE => "xref-range.out", $td->EXIT_STATUS => 0}, 62 {$td->FILE => "xref-range.out", $td->EXIT_STATUS => 0},
63 $td->NORMALIZE_NEWLINES); 63 $td->NORMALIZE_NEWLINES);
64 64
  65 +$td->runtest("extra text in xref table",
  66 + {$td->COMMAND => "qpdf --check bad-xref.pdf"},
  67 + {$td->STRING => "", $td->EXIT_STATUS => 3},
  68 + $td->EXPECT_FAILURE);
  69 +
65 cleanup(); 70 cleanup();
66 $td->report($n_tests); 71 $td->report($n_tests);