From 6884ad2eadff6795def2dd336a871227bc8c7d7e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 22 Aug 2017 07:19:41 -0400 Subject: [PATCH] Fix logic error in recovery A stray semicolon caused a condition to be incorrectly applied during stream length recovery. --- libqpdf/QPDF.cc | 2 +- qpdf/qtest/qpdf/issue-101.out | 2 +- qpdf/qtest/qpdf/issue-143.out | 2 -- qpdf/qtest/qpdf/issue-143.pdf | Bin 707 -> 710 bytes 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index f6e62546..caf5ef7b 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -1414,7 +1414,7 @@ QPDF::findEndstream() QPDFTokenizer::Token t = readToken(this->m->file, true); if ((t.getType() == QPDFTokenizer::tt_word) && ((t.getValue() == "endobj") || - (t.getValue() == "endstream"))); + (t.getValue() == "endstream"))) { this->m->file->seek(this->m->file->getLastOffset(), SEEK_SET); return true; diff --git a/qpdf/qtest/qpdf/issue-101.out b/qpdf/qtest/qpdf/issue-101.out index bd457c3a..e147baad 100644 --- a/qpdf/qtest/qpdf/issue-101.out +++ b/qpdf/qtest/qpdf/issue-101.out @@ -11,7 +11,7 @@ WARNING: issue-101.pdf (trailer, file position 1702): attempting to recover stre WARNING: issue-101.pdf (trailer, file position 1702): recovered stream length: 12 WARNING: issue-101.pdf (trailer, file position 2026): /Length key in stream dictionary is not an integer WARNING: issue-101.pdf (trailer, file position 2097): attempting to recover stream length -WARNING: issue-101.pdf (trailer, file position 2097): recovered stream length: 12 +WARNING: issue-101.pdf (trailer, file position 2097): recovered stream length: 257 WARNING: issue-101.pdf (trailer, file position 2613): /Length key in stream dictionary is not an integer WARNING: issue-101.pdf (trailer, file position 2684): attempting to recover stream length WARNING: issue-101.pdf (trailer, file position 2684): recovered stream length: 74 diff --git a/qpdf/qtest/qpdf/issue-143.out b/qpdf/qtest/qpdf/issue-143.out index 2bf1e40d..395065a0 100644 --- a/qpdf/qtest/qpdf/issue-143.out +++ b/qpdf/qtest/qpdf/issue-143.out @@ -3,7 +3,6 @@ WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): stream keyw WARNING: issue-143.pdf (xref stream: object 3 0, file position 607): stream dictionary lacks /Length key WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): attempting to recover stream length WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): recovered stream length: 36 -WARNING: issue-143.pdf (xref stream: object 3 0, file position 694): expected endobj WARNING: issue-143.pdf: file is damaged WARNING: issue-143.pdf (object 1 0, file position 48): expected n n obj 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 WARNING: issue-143.pdf (object 1 0, file position 21): stream dictionary lacks /Length key WARNING: issue-143.pdf (object 1 0, file position 84): attempting to recover stream length WARNING: issue-143.pdf (object 1 0, file position 84): recovered stream length: 606 -WARNING: issue-143.pdf (object 1 0, file position 694): expected endobj WARNING: object stream 1 (file position 33): expected dictionary key but found non-name object; inserting key /QPDFFake1 qpdf: operation succeeded with warnings; resulting file may have some problems diff --git a/qpdf/qtest/qpdf/issue-143.pdf b/qpdf/qtest/qpdf/issue-143.pdf index b45460361c1c239175b2e55aabd939830513e2e6..b62e68a2ded6f41fa63147ee375cc8376a36e876 100644 GIT binary patch delta 25 gcmX@idW?0$Rwlvxq%5xDlEk8tilWpsE;9oI0DO-K)Bpeg delta 22 dcmX@cdYE;?Rwh2K;*!Lol8U0#G%hm(0{~x-2bKT;