Commit 6884ad2eadff6795def2dd336a871227bc8c7d7e

Authored by Jay Berkenbilt
1 parent ce435222

Fix logic error in recovery

A stray semicolon caused a condition to be incorrectly applied during
stream length recovery.
libqpdf/QPDF.cc
@@ -1414,7 +1414,7 @@ QPDF::findEndstream() @@ -1414,7 +1414,7 @@ QPDF::findEndstream()
1414 QPDFTokenizer::Token t = readToken(this->m->file, true); 1414 QPDFTokenizer::Token t = readToken(this->m->file, true);
1415 if ((t.getType() == QPDFTokenizer::tt_word) && 1415 if ((t.getType() == QPDFTokenizer::tt_word) &&
1416 ((t.getValue() == "endobj") || 1416 ((t.getValue() == "endobj") ||
1417 - (t.getValue() == "endstream"))); 1417 + (t.getValue() == "endstream")))
1418 { 1418 {
1419 this->m->file->seek(this->m->file->getLastOffset(), SEEK_SET); 1419 this->m->file->seek(this->m->file->getLastOffset(), SEEK_SET);
1420 return true; 1420 return true;
qpdf/qtest/qpdf/issue-101.out
@@ -11,7 +11,7 @@ WARNING: issue-101.pdf (trailer, file position 1702): attempting to recover stre @@ -11,7 +11,7 @@ WARNING: issue-101.pdf (trailer, file position 1702): attempting to recover stre
11 WARNING: issue-101.pdf (trailer, file position 1702): recovered stream length: 12 11 WARNING: issue-101.pdf (trailer, file position 1702): recovered stream length: 12
12 WARNING: issue-101.pdf (trailer, file position 2026): /Length key in stream dictionary is not an integer 12 WARNING: issue-101.pdf (trailer, file position 2026): /Length key in stream dictionary is not an integer
13 WARNING: issue-101.pdf (trailer, file position 2097): attempting to recover stream length 13 WARNING: issue-101.pdf (trailer, file position 2097): attempting to recover stream length
14 -WARNING: issue-101.pdf (trailer, file position 2097): recovered stream length: 12 14 +WARNING: issue-101.pdf (trailer, file position 2097): recovered stream length: 257
15 WARNING: issue-101.pdf (trailer, file position 2613): /Length key in stream dictionary is not an integer 15 WARNING: issue-101.pdf (trailer, file position 2613): /Length key in stream dictionary is not an integer
16 WARNING: issue-101.pdf (trailer, file position 2684): attempting to recover stream length 16 WARNING: issue-101.pdf (trailer, file position 2684): attempting to recover stream length
17 WARNING: issue-101.pdf (trailer, file position 2684): recovered stream length: 74 17 WARNING: issue-101.pdf (trailer, file position 2684): recovered stream length: 74
qpdf/qtest/qpdf/issue-143.out
@@ -3,7 +3,6 @@ WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): stream keyw @@ -3,7 +3,6 @@ WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): stream keyw
3 WARNING: issue-143.pdf (xref stream: object 3 0, file position 607): stream dictionary lacks /Length key 3 WARNING: issue-143.pdf (xref stream: object 3 0, file position 607): stream dictionary lacks /Length key
4 WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): attempting to recover stream length 4 WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): attempting to recover stream length
5 WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): recovered stream length: 36 5 WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): recovered stream length: 36
6 -WARNING: issue-143.pdf (xref stream: object 3 0, file position 694): expected endobj  
7 WARNING: issue-143.pdf: file is damaged 6 WARNING: issue-143.pdf: file is damaged
8 WARNING: issue-143.pdf (object 1 0, file position 48): expected n n obj 7 WARNING: issue-143.pdf (object 1 0, file position 48): expected n n obj
9 WARNING: issue-143.pdf: Attempting to reconstruct cross-reference table 8 WARNING: issue-143.pdf: Attempting to reconstruct cross-reference table
@@ -14,6 +13,5 @@ WARNING: issue-143.pdf (file position 24): expected dictionary key but found non @@ -14,6 +13,5 @@ WARNING: issue-143.pdf (file position 24): expected dictionary key but found non
14 WARNING: issue-143.pdf (object 1 0, file position 21): stream dictionary lacks /Length key 13 WARNING: issue-143.pdf (object 1 0, file position 21): stream dictionary lacks /Length key
15 WARNING: issue-143.pdf (object 1 0, file position 84): attempting to recover stream length 14 WARNING: issue-143.pdf (object 1 0, file position 84): attempting to recover stream length
16 WARNING: issue-143.pdf (object 1 0, file position 84): recovered stream length: 606 15 WARNING: issue-143.pdf (object 1 0, file position 84): recovered stream length: 606
17 -WARNING: issue-143.pdf (object 1 0, file position 694): expected endobj  
18 WARNING: object stream 1 (file position 33): expected dictionary key but found non-name object; inserting key /QPDFFake1 16 WARNING: object stream 1 (file position 33): expected dictionary key but found non-name object; inserting key /QPDFFake1
19 qpdf: operation succeeded with warnings; resulting file may have some problems 17 qpdf: operation succeeded with warnings; resulting file may have some problems
qpdf/qtest/qpdf/issue-143.pdf
No preview for this file type