Commit b43a0ac2371b47c9bf73497a8b4853712dfdf3b8
1 parent
f37d399d
When recover stream length, indicate the length (fixes #44)
Showing
11 changed files
with
23 additions
and
0 deletions
ChangeLog
| 1 | 2017-07-29 Jay Berkenbilt <ejb@ql.org> | 1 | 2017-07-29 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | ||
| 3 | + * When recovering stream length, indicate the recovered length. | ||
| 4 | + Fixes #44. | ||
| 5 | + | ||
| 3 | * Add --newline-before-endstream command-line option and | 6 | * Add --newline-before-endstream command-line option and |
| 4 | setNewlineBeforeEndstream method to QPDFWriter. This forces qpdf | 7 | setNewlineBeforeEndstream method to QPDFWriter. This forces qpdf |
| 5 | to always add a newline before the endstream keyword. It is a | 8 | to always add a newline before the endstream keyword. It is a |
libqpdf/QPDF.cc
| @@ -1316,6 +1316,13 @@ QPDF::recoverStreamLength(PointerHolder<InputSource> input, | @@ -1316,6 +1316,13 @@ QPDF::recoverStreamLength(PointerHolder<InputSource> input, | ||
| 1316 | this->last_object_description, stream_offset, | 1316 | this->last_object_description, stream_offset, |
| 1317 | "unable to recover stream data; treating stream as empty")); | 1317 | "unable to recover stream data; treating stream as empty")); |
| 1318 | } | 1318 | } |
| 1319 | + else | ||
| 1320 | + { | ||
| 1321 | + warn(QPDFExc(qpdf_e_damaged_pdf, input->getName(), | ||
| 1322 | + this->last_object_description, stream_offset, | ||
| 1323 | + "recovered stream length: " + | ||
| 1324 | + QUtil::int_to_string(length))); | ||
| 1325 | + } | ||
| 1319 | 1326 | ||
| 1320 | QTC::TC("qpdf", "QPDF recovered stream length"); | 1327 | QTC::TC("qpdf", "QPDF recovered stream length"); |
| 1321 | return length; | 1328 | return length; |
qpdf/qtest/qpdf/bad22-recover.out
| 1 | WARNING: bad22.pdf (object 4 0, file position 314): stream dictionary lacks /Length key | 1 | WARNING: bad22.pdf (object 4 0, file position 314): stream dictionary lacks /Length key |
| 2 | WARNING: bad22.pdf (object 4 0, file position 341): attempting to recover stream length | 2 | WARNING: bad22.pdf (object 4 0, file position 341): attempting to recover stream length |
| 3 | +WARNING: bad22.pdf (object 4 0, file position 341): recovered stream length: 44 | ||
| 3 | /QTest is indirect and has type stream (10) | 4 | /QTest is indirect and has type stream (10) |
| 4 | /QTest is a stream. Dictionary: << /Qength 44 >> | 5 | /QTest is a stream. Dictionary: << /Qength 44 >> |
| 5 | Raw stream data: | 6 | Raw stream data: |
qpdf/qtest/qpdf/bad23-recover.out
| 1 | WARNING: bad23.pdf (object 4 0, file position 314): /Length key in stream dictionary is not an integer | 1 | WARNING: bad23.pdf (object 4 0, file position 314): /Length key in stream dictionary is not an integer |
| 2 | WARNING: bad23.pdf (object 4 0, file position 341): attempting to recover stream length | 2 | WARNING: bad23.pdf (object 4 0, file position 341): attempting to recover stream length |
| 3 | +WARNING: bad23.pdf (object 4 0, file position 341): recovered stream length: 44 | ||
| 3 | /QTest is indirect and has type stream (10) | 4 | /QTest is indirect and has type stream (10) |
| 4 | /QTest is a stream. Dictionary: << /Length () >> | 5 | /QTest is a stream. Dictionary: << /Length () >> |
| 5 | Raw stream data: | 6 | Raw stream data: |
qpdf/qtest/qpdf/heifer.out
| @@ -3,4 +3,5 @@ WARNING: heifer.pdf (file position 92741): xref not found | @@ -3,4 +3,5 @@ WARNING: heifer.pdf (file position 92741): xref not found | ||
| 3 | WARNING: heifer.pdf: Attempting to reconstruct cross-reference table | 3 | WARNING: heifer.pdf: Attempting to reconstruct cross-reference table |
| 4 | WARNING: heifer.pdf (object 2 0, file position 2165): expected endstream | 4 | WARNING: heifer.pdf (object 2 0, file position 2165): expected endstream |
| 5 | WARNING: heifer.pdf (object 2 0, file position 51): attempting to recover stream length | 5 | WARNING: heifer.pdf (object 2 0, file position 51): attempting to recover stream length |
| 6 | +WARNING: heifer.pdf (object 2 0, file position 51): recovered stream length: 2249 | ||
| 6 | qpdf: operation succeeded with warnings; resulting file may have some problems | 7 | qpdf: operation succeeded with warnings; resulting file may have some problems |
qpdf/qtest/qpdf/issue-100.out
| @@ -10,6 +10,7 @@ WARNING: issue-100.pdf (file position 304): unknown token while reading object; | @@ -10,6 +10,7 @@ WARNING: issue-100.pdf (file position 304): unknown token while reading object; | ||
| 10 | WARNING: issue-100.pdf (file position 308): unexpected ) | 10 | WARNING: issue-100.pdf (file position 308): unexpected ) |
| 11 | WARNING: issue-100.pdf (object 5 0, file position 418): /Length key in stream dictionary is not an integer | 11 | WARNING: issue-100.pdf (object 5 0, file position 418): /Length key in stream dictionary is not an integer |
| 12 | WARNING: issue-100.pdf (object 5 0, file position 489): attempting to recover stream length | 12 | WARNING: issue-100.pdf (object 5 0, file position 489): attempting to recover stream length |
| 13 | +WARNING: issue-100.pdf (object 5 0, file position 489): recovered stream length: 12 | ||
| 13 | WARNING: issue-100.pdf (trailer, file position 953): expected dictionary key but found non-name object; inserting key /QPDFFake1 | 14 | WARNING: issue-100.pdf (trailer, file position 953): expected dictionary key but found non-name object; inserting key /QPDFFake1 |
| 14 | WARNING: issue-100.pdf (trailer, file position 953): dictionary ended prematurely; using null as value for last key | 15 | WARNING: issue-100.pdf (trailer, file position 953): dictionary ended prematurely; using null as value for last key |
| 15 | issue-100.pdf (file position 1138): unable to find /Root dictionary | 16 | issue-100.pdf (file position 1138): unable to find /Root dictionary |
qpdf/qtest/qpdf/issue-101.out
| @@ -5,8 +5,10 @@ WARNING: issue-101.pdf (file position 1242): expected dictionary key but found n | @@ -5,8 +5,10 @@ WARNING: issue-101.pdf (file position 1242): expected dictionary key but found n | ||
| 5 | WARNING: issue-101.pdf (file position 1242): dictionary ended prematurely; using null as value for last key | 5 | WARNING: issue-101.pdf (file position 1242): dictionary ended prematurely; using null as value for last key |
| 6 | WARNING: issue-101.pdf (object 5 0, file position 1438): /Length key in stream dictionary is not an integer | 6 | WARNING: issue-101.pdf (object 5 0, file position 1438): /Length key in stream dictionary is not an integer |
| 7 | WARNING: issue-101.pdf (object 5 0, file position 1509): attempting to recover stream length | 7 | WARNING: issue-101.pdf (object 5 0, file position 1509): attempting to recover stream length |
| 8 | +WARNING: issue-101.pdf (object 5 0, file position 1509): recovered stream length: 205 | ||
| 8 | WARNING: issue-101.pdf (trailer, file position 2026): /Length key in stream dictionary is not an integer | 9 | WARNING: issue-101.pdf (trailer, file position 2026): /Length key in stream dictionary is not an integer |
| 9 | WARNING: issue-101.pdf (trailer, file position 2097): attempting to recover stream length | 10 | WARNING: issue-101.pdf (trailer, file position 2097): attempting to recover stream length |
| 11 | +WARNING: issue-101.pdf (trailer, file position 2097): recovered stream length: 709 | ||
| 10 | WARNING: issue-101.pdf (trailer, file position 2928): unknown token while reading object; treating as string | 12 | WARNING: issue-101.pdf (trailer, file position 2928): unknown token while reading object; treating as string |
| 11 | WARNING: issue-101.pdf (trailer, file position 2930): unknown token while reading object; treating as string | 13 | WARNING: issue-101.pdf (trailer, file position 2930): unknown token while reading object; treating as string |
| 12 | WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake1 | 14 | WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake1 |
| @@ -14,10 +16,13 @@ WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key bu | @@ -14,10 +16,13 @@ WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key bu | ||
| 14 | WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake3 | 16 | WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake3 |
| 15 | WARNING: issue-101.pdf (trailer, file position 2925): /Length key in stream dictionary is not an integer | 17 | WARNING: issue-101.pdf (trailer, file position 2925): /Length key in stream dictionary is not an integer |
| 16 | WARNING: issue-101.pdf (trailer, file position 2996): attempting to recover stream length | 18 | WARNING: issue-101.pdf (trailer, file position 2996): attempting to recover stream length |
| 19 | +WARNING: issue-101.pdf (trailer, file position 2996): recovered stream length: 12 | ||
| 17 | WARNING: issue-101.pdf (trailer, file position 3339): /Length key in stream dictionary is not an integer | 20 | WARNING: issue-101.pdf (trailer, file position 3339): /Length key in stream dictionary is not an integer |
| 18 | WARNING: issue-101.pdf (trailer, file position 3410): attempting to recover stream length | 21 | WARNING: issue-101.pdf (trailer, file position 3410): attempting to recover stream length |
| 22 | +WARNING: issue-101.pdf (trailer, file position 3410): recovered stream length: 12 | ||
| 19 | WARNING: issue-101.pdf (trailer, file position 3560): /Length key in stream dictionary is not an integer | 23 | WARNING: issue-101.pdf (trailer, file position 3560): /Length key in stream dictionary is not an integer |
| 20 | WARNING: issue-101.pdf (trailer, file position 3631): attempting to recover stream length | 24 | WARNING: issue-101.pdf (trailer, file position 3631): attempting to recover stream length |
| 25 | +WARNING: issue-101.pdf (trailer, file position 3631): recovered stream length: 167 | ||
| 21 | WARNING: issue-101.pdf (trailer, file position 4113): /Length key in stream dictionary is not an integer | 26 | WARNING: issue-101.pdf (trailer, file position 4113): /Length key in stream dictionary is not an integer |
| 22 | WARNING: issue-101.pdf (trailer, file position 4184): attempting to recover stream length | 27 | WARNING: issue-101.pdf (trailer, file position 4184): attempting to recover stream length |
| 23 | WARNING: issue-101.pdf (trailer, file position 4184): unable to recover stream data; treating stream as empty | 28 | WARNING: issue-101.pdf (trailer, file position 4184): unable to recover stream data; treating stream as empty |
qpdf/qtest/qpdf/issue-117.out
| @@ -4,4 +4,5 @@ WARNING: issue-117.pdf: Attempting to reconstruct cross-reference table | @@ -4,4 +4,5 @@ WARNING: issue-117.pdf: Attempting to reconstruct cross-reference table | ||
| 4 | WARNING: issue-117.pdf (file position 66): loop detected resolving object 2 0 | 4 | WARNING: issue-117.pdf (file position 66): loop detected resolving object 2 0 |
| 5 | WARNING: issue-117.pdf (object 2 0, file position 22): /Length key in stream dictionary is not an integer | 5 | WARNING: issue-117.pdf (object 2 0, file position 22): /Length key in stream dictionary is not an integer |
| 6 | WARNING: issue-117.pdf (object 2 0, file position 67): attempting to recover stream length | 6 | WARNING: issue-117.pdf (object 2 0, file position 67): attempting to recover stream length |
| 7 | +WARNING: issue-117.pdf (object 2 0, file position 67): recovered stream length: 91 | ||
| 7 | attempt to make a stream into a direct object | 8 | attempt to make a stream into a direct object |
qpdf/qtest/qpdf/linearization-bounds-1.out
| @@ -4,4 +4,5 @@ File is not encrypted | @@ -4,4 +4,5 @@ File is not encrypted | ||
| 4 | File is linearized | 4 | File is linearized |
| 5 | WARNING: linearization-bounds-1.pdf (linearization hint stream: object 62 0, file position 1001182): EOF while reading token | 5 | WARNING: linearization-bounds-1.pdf (linearization hint stream: object 62 0, file position 1001182): EOF while reading token |
| 6 | WARNING: linearization-bounds-1.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length | 6 | WARNING: linearization-bounds-1.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length |
| 7 | +WARNING: linearization-bounds-1.pdf (linearization hint stream: object 62 0, file position 1183): recovered stream length: 106 | ||
| 7 | linearization-bounds-1.pdf (linearization hint table, file position 1183): /S (shared object) offset is out of bounds | 8 | linearization-bounds-1.pdf (linearization hint table, file position 1183): /S (shared object) offset is out of bounds |
qpdf/qtest/qpdf/linearization-bounds-2.out
| @@ -4,4 +4,5 @@ File is not encrypted | @@ -4,4 +4,5 @@ File is not encrypted | ||
| 4 | File is linearized | 4 | File is linearized |
| 5 | WARNING: linearization-bounds-2.pdf (linearization hint stream: object 62 0, file position 1282): expected endstream | 5 | WARNING: linearization-bounds-2.pdf (linearization hint stream: object 62 0, file position 1282): expected endstream |
| 6 | WARNING: linearization-bounds-2.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length | 6 | WARNING: linearization-bounds-2.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length |
| 7 | +WARNING: linearization-bounds-2.pdf (linearization hint stream: object 62 0, file position 1183): recovered stream length: 106 | ||
| 7 | linearization-bounds-2.pdf (linearization hint table, file position 1183): /S (shared object) offset is out of bounds | 8 | linearization-bounds-2.pdf (linearization hint table, file position 1183): /S (shared object) offset is out of bounds |
qpdf/qtest/qpdf/linearization-large-vector-alloc.out
| @@ -4,4 +4,5 @@ File is not encrypted | @@ -4,4 +4,5 @@ File is not encrypted | ||
| 4 | File is linearized | 4 | File is linearized |
| 5 | WARNING: linearization-large-vector-alloc.pdf (linearization hint stream: object 62 0, file position 1282): expected endstream | 5 | WARNING: linearization-large-vector-alloc.pdf (linearization hint stream: object 62 0, file position 1282): expected endstream |
| 6 | WARNING: linearization-large-vector-alloc.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length | 6 | WARNING: linearization-large-vector-alloc.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length |
| 7 | +WARNING: linearization-large-vector-alloc.pdf (linearization hint stream: object 62 0, file position 1183): recovered stream length: 106 | ||
| 7 | overflow reading bit stream | 8 | overflow reading bit stream |