Commit 1bce5c4ff95ee420f3459891d6496c40d413d4bf
1 parent
95a45263
Fix object stream error/warning messages reporting wrong object id
This was due to the use of last_object_description, which is not set for the object stream itself. Also, modify the messages introduced #1391 and #1392 to report the supposed offset of the objects.
Showing
4 changed files
with
19 additions
and
13 deletions
libqpdf/QPDF_objects.cc
| ... | ... | @@ -1613,6 +1613,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number) |
| 1613 | 1613 | QPDFObjectHandle obj_stream = getObjectByID(obj_stream_number, 0); |
| 1614 | 1614 | if (!obj_stream.isStream()) { |
| 1615 | 1615 | throw damagedPDF( |
| 1616 | + "object " + std::to_string(obj_stream_number) + " 0", | |
| 1616 | 1617 | "supposed object stream " + std::to_string(obj_stream_number) + " is not a stream"); |
| 1617 | 1618 | } |
| 1618 | 1619 | |
| ... | ... | @@ -1626,12 +1627,14 @@ QPDF::resolveObjectsInStream(int obj_stream_number) |
| 1626 | 1627 | if (!dict.isDictionaryOfType("/ObjStm")) { |
| 1627 | 1628 | QTC::TC("qpdf", "QPDF ERR object stream with wrong type"); |
| 1628 | 1629 | warn(damagedPDF( |
| 1630 | + "object " + std::to_string(obj_stream_number) + " 0", | |
| 1629 | 1631 | "supposed object stream " + std::to_string(obj_stream_number) + " has wrong type")); |
| 1630 | 1632 | } |
| 1631 | 1633 | |
| 1632 | 1634 | if (!(dict.getKey("/N").isInteger() && dict.getKey("/First").isInteger())) { |
| 1633 | 1635 | throw damagedPDF( |
| 1634 | - ("object stream " + std::to_string(obj_stream_number) + " has incorrect keys")); | |
| 1636 | + "object " + std::to_string(obj_stream_number) + " 0", | |
| 1637 | + "object stream " + std::to_string(obj_stream_number) + " has incorrect keys"); | |
| 1635 | 1638 | } |
| 1636 | 1639 | |
| 1637 | 1640 | int n = dict.getKey("/N").getIntValueAsInt(); |
| ... | ... | @@ -1653,7 +1656,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number) |
| 1653 | 1656 | if (!(tnum.isInteger() && toffset.isInteger())) { |
| 1654 | 1657 | throw damagedPDF( |
| 1655 | 1658 | *input, |
| 1656 | - m->last_object_description, | |
| 1659 | + "object " + std::to_string(obj_stream_number) + " 0", | |
| 1657 | 1660 | input->getLastOffset(), |
| 1658 | 1661 | "expected integer in object stream header"); |
| 1659 | 1662 | } |
| ... | ... | @@ -1665,7 +1668,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number) |
| 1665 | 1668 | QTC::TC("qpdf", "QPDF ignore self-referential object stream"); |
| 1666 | 1669 | warn(damagedPDF( |
| 1667 | 1670 | *input, |
| 1668 | - m->last_object_description, | |
| 1671 | + "object " + std::to_string(obj_stream_number) + " 0", | |
| 1669 | 1672 | input->getLastOffset(), |
| 1670 | 1673 | "object stream claims to contain itself")); |
| 1671 | 1674 | continue; |
| ... | ... | @@ -1675,8 +1678,8 @@ QPDF::resolveObjectsInStream(int obj_stream_number) |
| 1675 | 1678 | QTC::TC("qpdf", "QPDF object stream contains id < 1"); |
| 1676 | 1679 | warn(damagedPDF( |
| 1677 | 1680 | *input, |
| 1678 | - "object "s + std::to_string(num) + " 0, offset " + std::to_string(offset), | |
| 1679 | - 0, | |
| 1681 | + "object " + std::to_string(num) + " 0", | |
| 1682 | + input->getLastOffset(), | |
| 1680 | 1683 | "object id is invalid"s)); |
| 1681 | 1684 | continue; |
| 1682 | 1685 | } |
| ... | ... | @@ -1685,8 +1688,8 @@ QPDF::resolveObjectsInStream(int obj_stream_number) |
| 1685 | 1688 | QTC::TC("qpdf", "QPDF object stream offsets not increasing"); |
| 1686 | 1689 | warn(damagedPDF( |
| 1687 | 1690 | *input, |
| 1688 | - "object "s + std::to_string(num) + " 0, offset " + std::to_string(offset), | |
| 1689 | - 0, | |
| 1691 | + "object " + std::to_string(num) + " 0", | |
| 1692 | + offset, | |
| 1690 | 1693 | "offset is invalid (must be larger than previous offset " + |
| 1691 | 1694 | std::to_string(last_offset) + ")")); |
| 1692 | 1695 | continue; | ... | ... |
manual/release-notes.rst
| ... | ... | @@ -21,6 +21,9 @@ more detail. |
| 21 | 21 | integer object. Previously the method returned false if the first |
| 22 | 22 | dictionary object was not a linearization parameter dictionary. |
| 23 | 23 | |
| 24 | + - Fix two object stream error/warning messages that reported the wrong | |
| 25 | + object id. | |
| 26 | + | |
| 24 | 27 | - Other enhancements |
| 25 | 28 | |
| 26 | 29 | - There have been further enhancements to how files with damaged xref | ... | ... |
qpdf/qtest/qpdf/fuzz-16214.out
| ... | ... | @@ -16,8 +16,8 @@ WARNING: fuzz-16214.pdf (object 1 0, offset 7189): expected n n obj |
| 16 | 16 | WARNING: fuzz-16214.pdf: Attempting to reconstruct cross-reference table |
| 17 | 17 | WARNING: fuzz-16214.pdf (offset 7207): error decoding stream data for object 2 0: stream inflate: inflate: data: invalid code lengths set |
| 18 | 18 | WARNING: fuzz-16214.pdf (offset 7207): getStreamData called on unfilterable stream |
| 19 | -WARNING: fuzz-16214.pdf (object 7 0, offset 7207): supposed object stream 5 has wrong type | |
| 20 | -WARNING: fuzz-16214.pdf (object 7 0, offset 7207): object stream 5 has incorrect keys | |
| 19 | +WARNING: fuzz-16214.pdf (object 5 0, offset 7207): supposed object stream 5 has wrong type | |
| 20 | +WARNING: fuzz-16214.pdf (object 5 0, offset 7207): object stream 5 has incorrect keys | |
| 21 | 21 | WARNING: fuzz-16214.pdf (object 21 0, offset 3639): expected endstream |
| 22 | 22 | WARNING: fuzz-16214.pdf (object 21 0, offset 3112): attempting to recover stream length |
| 23 | 23 | WARNING: fuzz-16214.pdf (object 21 0, offset 3112): recovered stream length: 340 | ... | ... |
qpdf/qtest/qpdf/issue-143.out
| ... | ... | @@ -14,9 +14,9 @@ WARNING: issue-143.pdf (object 1 0, offset 24): expected dictionary key but foun |
| 14 | 14 | WARNING: issue-143.pdf (object 1 0, offset 21): stream dictionary lacks /Length key |
| 15 | 15 | WARNING: issue-143.pdf (object 1 0, offset 84): attempting to recover stream length |
| 16 | 16 | WARNING: issue-143.pdf (object 1 0, offset 84): recovered stream length: 606 |
| 17 | -WARNING: issue-143.pdf object stream 1 (object 0 0, offset 0): object id is invalid | |
| 18 | -WARNING: issue-143.pdf object stream 1 (object 0 0, offset 0): object id is invalid | |
| 19 | -WARNING: issue-143.pdf object stream 1 (object 6 0, offset 0): offset is invalid (must be larger than previous offset 0) | |
| 20 | -WARNING: issue-143.pdf object stream 1 (object 0 0, offset 0): object id is invalid | |
| 17 | +WARNING: issue-143.pdf object stream 1 (object 0 0, offset 4): object id is invalid | |
| 18 | +WARNING: issue-143.pdf object stream 1 (object 0 0, offset 15): object id is invalid | |
| 19 | +WARNING: issue-143.pdf object stream 1 (object 6 0): offset is invalid (must be larger than previous offset 0) | |
| 20 | +WARNING: issue-143.pdf object stream 1 (object 0 0, offset 27): object id is invalid | |
| 21 | 21 | WARNING: issue-143.pdf object stream 1 (object 2 0, offset 33): expected dictionary key but found non-name object; inserting key /QPDFFake1 |
| 22 | 22 | qpdf: issue-143.pdf: unable to find page tree | ... | ... |