2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

When recover stream length, indicate the length (fixes #44)

This commit is contained in:
Jay Berkenbilt 2017-07-29 19:15:06 -04:00
parent f37d399d82
commit b43a0ac237
11 changed files with 23 additions and 0 deletions

View File

@ -1,5 +1,8 @@
2017-07-29 Jay Berkenbilt <ejb@ql.org> 2017-07-29 Jay Berkenbilt <ejb@ql.org>
* When recovering stream length, indicate the recovered length.
Fixes #44.
* Add --newline-before-endstream command-line option and * Add --newline-before-endstream command-line option and
setNewlineBeforeEndstream method to QPDFWriter. This forces qpdf setNewlineBeforeEndstream method to QPDFWriter. This forces qpdf
to always add a newline before the endstream keyword. It is a to always add a newline before the endstream keyword. It is a

View File

@ -1316,6 +1316,13 @@ QPDF::recoverStreamLength(PointerHolder<InputSource> input,
this->last_object_description, stream_offset, this->last_object_description, stream_offset,
"unable to recover stream data; treating stream as empty")); "unable to recover stream data; treating stream as empty"));
} }
else
{
warn(QPDFExc(qpdf_e_damaged_pdf, input->getName(),
this->last_object_description, stream_offset,
"recovered stream length: " +
QUtil::int_to_string(length)));
}
QTC::TC("qpdf", "QPDF recovered stream length"); QTC::TC("qpdf", "QPDF recovered stream length");
return length; return length;

View File

@ -1,5 +1,6 @@
WARNING: bad22.pdf (object 4 0, file position 314): stream dictionary lacks /Length key WARNING: bad22.pdf (object 4 0, file position 314): stream dictionary lacks /Length key
WARNING: bad22.pdf (object 4 0, file position 341): attempting to recover stream length WARNING: bad22.pdf (object 4 0, file position 341): attempting to recover stream length
WARNING: bad22.pdf (object 4 0, file position 341): recovered stream length: 44
/QTest is indirect and has type stream (10) /QTest is indirect and has type stream (10)
/QTest is a stream. Dictionary: << /Qength 44 >> /QTest is a stream. Dictionary: << /Qength 44 >>
Raw stream data: Raw stream data:

View File

@ -1,5 +1,6 @@
WARNING: bad23.pdf (object 4 0, file position 314): /Length key in stream dictionary is not an integer WARNING: bad23.pdf (object 4 0, file position 314): /Length key in stream dictionary is not an integer
WARNING: bad23.pdf (object 4 0, file position 341): attempting to recover stream length WARNING: bad23.pdf (object 4 0, file position 341): attempting to recover stream length
WARNING: bad23.pdf (object 4 0, file position 341): recovered stream length: 44
/QTest is indirect and has type stream (10) /QTest is indirect and has type stream (10)
/QTest is a stream. Dictionary: << /Length () >> /QTest is a stream. Dictionary: << /Length () >>
Raw stream data: Raw stream data:

View File

@ -3,4 +3,5 @@ WARNING: heifer.pdf (file position 92741): xref not found
WARNING: heifer.pdf: Attempting to reconstruct cross-reference table WARNING: heifer.pdf: Attempting to reconstruct cross-reference table
WARNING: heifer.pdf (object 2 0, file position 2165): expected endstream WARNING: heifer.pdf (object 2 0, file position 2165): expected endstream
WARNING: heifer.pdf (object 2 0, file position 51): attempting to recover stream length WARNING: heifer.pdf (object 2 0, file position 51): attempting to recover stream length
WARNING: heifer.pdf (object 2 0, file position 51): recovered stream length: 2249
qpdf: operation succeeded with warnings; resulting file may have some problems qpdf: operation succeeded with warnings; resulting file may have some problems

View File

@ -10,6 +10,7 @@ WARNING: issue-100.pdf (file position 304): unknown token while reading object;
WARNING: issue-100.pdf (file position 308): unexpected ) WARNING: issue-100.pdf (file position 308): unexpected )
WARNING: issue-100.pdf (object 5 0, file position 418): /Length key in stream dictionary is not an integer WARNING: issue-100.pdf (object 5 0, file position 418): /Length key in stream dictionary is not an integer
WARNING: issue-100.pdf (object 5 0, file position 489): attempting to recover stream length WARNING: issue-100.pdf (object 5 0, file position 489): attempting to recover stream length
WARNING: issue-100.pdf (object 5 0, file position 489): recovered stream length: 12
WARNING: issue-100.pdf (trailer, file position 953): expected dictionary key but found non-name object; inserting key /QPDFFake1 WARNING: issue-100.pdf (trailer, file position 953): expected dictionary key but found non-name object; inserting key /QPDFFake1
WARNING: issue-100.pdf (trailer, file position 953): dictionary ended prematurely; using null as value for last key WARNING: issue-100.pdf (trailer, file position 953): dictionary ended prematurely; using null as value for last key
issue-100.pdf (file position 1138): unable to find /Root dictionary issue-100.pdf (file position 1138): unable to find /Root dictionary

View File

@ -5,8 +5,10 @@ WARNING: issue-101.pdf (file position 1242): expected dictionary key but found n
WARNING: issue-101.pdf (file position 1242): dictionary ended prematurely; using null as value for last key WARNING: issue-101.pdf (file position 1242): dictionary ended prematurely; using null as value for last key
WARNING: issue-101.pdf (object 5 0, file position 1438): /Length key in stream dictionary is not an integer WARNING: issue-101.pdf (object 5 0, file position 1438): /Length key in stream dictionary is not an integer
WARNING: issue-101.pdf (object 5 0, file position 1509): attempting to recover stream length WARNING: issue-101.pdf (object 5 0, file position 1509): attempting to recover stream length
WARNING: issue-101.pdf (object 5 0, file position 1509): recovered stream length: 205
WARNING: issue-101.pdf (trailer, file position 2026): /Length key in stream dictionary is not an integer 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): attempting to recover stream length
WARNING: issue-101.pdf (trailer, file position 2097): recovered stream length: 709
WARNING: issue-101.pdf (trailer, file position 2928): unknown token while reading object; treating as string WARNING: issue-101.pdf (trailer, file position 2928): unknown token while reading object; treating as string
WARNING: issue-101.pdf (trailer, file position 2930): unknown token while reading object; treating as string WARNING: issue-101.pdf (trailer, file position 2930): unknown token while reading object; treating as string
WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake1 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
WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake3 WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake3
WARNING: issue-101.pdf (trailer, file position 2925): /Length key in stream dictionary is not an integer WARNING: issue-101.pdf (trailer, file position 2925): /Length key in stream dictionary is not an integer
WARNING: issue-101.pdf (trailer, file position 2996): attempting to recover stream length WARNING: issue-101.pdf (trailer, file position 2996): attempting to recover stream length
WARNING: issue-101.pdf (trailer, file position 2996): recovered stream length: 12
WARNING: issue-101.pdf (trailer, file position 3339): /Length key in stream dictionary is not an integer WARNING: issue-101.pdf (trailer, file position 3339): /Length key in stream dictionary is not an integer
WARNING: issue-101.pdf (trailer, file position 3410): attempting to recover stream length WARNING: issue-101.pdf (trailer, file position 3410): attempting to recover stream length
WARNING: issue-101.pdf (trailer, file position 3410): recovered stream length: 12
WARNING: issue-101.pdf (trailer, file position 3560): /Length key in stream dictionary is not an integer WARNING: issue-101.pdf (trailer, file position 3560): /Length key in stream dictionary is not an integer
WARNING: issue-101.pdf (trailer, file position 3631): attempting to recover stream length WARNING: issue-101.pdf (trailer, file position 3631): attempting to recover stream length
WARNING: issue-101.pdf (trailer, file position 3631): recovered stream length: 167
WARNING: issue-101.pdf (trailer, file position 4113): /Length key in stream dictionary is not an integer WARNING: issue-101.pdf (trailer, file position 4113): /Length key in stream dictionary is not an integer
WARNING: issue-101.pdf (trailer, file position 4184): attempting to recover stream length WARNING: issue-101.pdf (trailer, file position 4184): attempting to recover stream length
WARNING: issue-101.pdf (trailer, file position 4184): unable to recover stream data; treating stream as empty WARNING: issue-101.pdf (trailer, file position 4184): unable to recover stream data; treating stream as empty

View File

@ -4,4 +4,5 @@ WARNING: issue-117.pdf: Attempting to reconstruct cross-reference table
WARNING: issue-117.pdf (file position 66): loop detected resolving object 2 0 WARNING: issue-117.pdf (file position 66): loop detected resolving object 2 0
WARNING: issue-117.pdf (object 2 0, file position 22): /Length key in stream dictionary is not an integer WARNING: issue-117.pdf (object 2 0, file position 22): /Length key in stream dictionary is not an integer
WARNING: issue-117.pdf (object 2 0, file position 67): attempting to recover stream length WARNING: issue-117.pdf (object 2 0, file position 67): attempting to recover stream length
WARNING: issue-117.pdf (object 2 0, file position 67): recovered stream length: 91
attempt to make a stream into a direct object attempt to make a stream into a direct object

View File

@ -4,4 +4,5 @@ File is not encrypted
File is linearized File is linearized
WARNING: linearization-bounds-1.pdf (linearization hint stream: object 62 0, file position 1001182): EOF while reading token WARNING: linearization-bounds-1.pdf (linearization hint stream: object 62 0, file position 1001182): EOF while reading token
WARNING: linearization-bounds-1.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length WARNING: linearization-bounds-1.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length
WARNING: linearization-bounds-1.pdf (linearization hint stream: object 62 0, file position 1183): recovered stream length: 106
linearization-bounds-1.pdf (linearization hint table, file position 1183): /S (shared object) offset is out of bounds linearization-bounds-1.pdf (linearization hint table, file position 1183): /S (shared object) offset is out of bounds

View File

@ -4,4 +4,5 @@ File is not encrypted
File is linearized File is linearized
WARNING: linearization-bounds-2.pdf (linearization hint stream: object 62 0, file position 1282): expected endstream WARNING: linearization-bounds-2.pdf (linearization hint stream: object 62 0, file position 1282): expected endstream
WARNING: linearization-bounds-2.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length WARNING: linearization-bounds-2.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length
WARNING: linearization-bounds-2.pdf (linearization hint stream: object 62 0, file position 1183): recovered stream length: 106
linearization-bounds-2.pdf (linearization hint table, file position 1183): /S (shared object) offset is out of bounds linearization-bounds-2.pdf (linearization hint table, file position 1183): /S (shared object) offset is out of bounds

View File

@ -4,4 +4,5 @@ File is not encrypted
File is linearized File is linearized
WARNING: linearization-large-vector-alloc.pdf (linearization hint stream: object 62 0, file position 1282): expected endstream WARNING: linearization-large-vector-alloc.pdf (linearization hint stream: object 62 0, file position 1282): expected endstream
WARNING: linearization-large-vector-alloc.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length WARNING: linearization-large-vector-alloc.pdf (linearization hint stream: object 62 0, file position 1183): attempting to recover stream length
WARNING: linearization-large-vector-alloc.pdf (linearization hint stream: object 62 0, file position 1183): recovered stream length: 106
overflow reading bit stream overflow reading bit stream