Commit 60c7d594b835ae2eac8235658179aedce7b3b007
1 parent
972cbf10
In QPDF::filterCompressedObjects ignore objects not in QPDFWriter tables
Add fuzz case 68377.
Showing
5 changed files
with
22 additions
and
11 deletions
fuzz/CMakeLists.txt
| @@ -114,6 +114,7 @@ set(CORPUS_OTHER | @@ -114,6 +114,7 @@ set(CORPUS_OTHER | ||
| 114 | 65681.fuzz | 114 | 65681.fuzz |
| 115 | 65773.fuzz | 115 | 65773.fuzz |
| 116 | 65777.fuzz | 116 | 65777.fuzz |
| 117 | + 68377.fuzz | ||
| 117 | ) | 118 | ) |
| 118 | 119 | ||
| 119 | set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus) | 120 | set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus) |
fuzz/qpdf_extra/68377.fuzz
0 → 100644
No preview for this file type
fuzz/qtest/fuzz.test
| @@ -21,7 +21,7 @@ my @fuzzers = ( | @@ -21,7 +21,7 @@ my @fuzzers = ( | ||
| 21 | ['pngpredictor' => 1], | 21 | ['pngpredictor' => 1], |
| 22 | ['runlength' => 6], | 22 | ['runlength' => 6], |
| 23 | ['tiffpredictor' => 2], | 23 | ['tiffpredictor' => 2], |
| 24 | - ['qpdf' => 56], # increment when adding new files | 24 | + ['qpdf' => 57], # increment when adding new files |
| 25 | ); | 25 | ); |
| 26 | 26 | ||
| 27 | my $n_tests = 0; | 27 | my $n_tests = 0; |
libqpdf/QPDF_optimization.cc
| @@ -416,22 +416,26 @@ QPDF::filterCompressedObjects(QPDFWriter::ObjTable const& obj) | @@ -416,22 +416,26 @@ QPDF::filterCompressedObjects(QPDFWriter::ObjTable const& obj) | ||
| 416 | ObjUser const& ou = i1.first; | 416 | ObjUser const& ou = i1.first; |
| 417 | // Loop over objects. | 417 | // Loop over objects. |
| 418 | for (auto const& og: i1.second) { | 418 | for (auto const& og: i1.second) { |
| 419 | - if (auto const& i2 = obj[og].object_stream; i2 <= 0) { | ||
| 420 | - t_obj_user_to_objects[ou].insert(og); | ||
| 421 | - } else { | ||
| 422 | - t_obj_user_to_objects[ou].insert(QPDFObjGen(i2, 0)); | 419 | + if (obj.contains(og)) { |
| 420 | + if (auto const& i2 = obj[og].object_stream; i2 <= 0) { | ||
| 421 | + t_obj_user_to_objects[ou].insert(og); | ||
| 422 | + } else { | ||
| 423 | + t_obj_user_to_objects[ou].insert(QPDFObjGen(i2, 0)); | ||
| 424 | + } | ||
| 423 | } | 425 | } |
| 424 | } | 426 | } |
| 425 | } | 427 | } |
| 426 | 428 | ||
| 427 | for (auto const& i1: m->object_to_obj_users) { | 429 | for (auto const& i1: m->object_to_obj_users) { |
| 428 | QPDFObjGen const& og = i1.first; | 430 | QPDFObjGen const& og = i1.first; |
| 429 | - // Loop over obj_users. | ||
| 430 | - for (auto const& ou: i1.second) { | ||
| 431 | - if (auto i2 = obj[og].object_stream; i2 <= 0) { | ||
| 432 | - t_object_to_obj_users[og].insert(ou); | ||
| 433 | - } else { | ||
| 434 | - t_object_to_obj_users[QPDFObjGen(i2, 0)].insert(ou); | 431 | + if (obj.contains(og)) { |
| 432 | + // Loop over obj_users. | ||
| 433 | + for (auto const& ou: i1.second) { | ||
| 434 | + if (auto i2 = obj[og].object_stream; i2 <= 0) { | ||
| 435 | + t_object_to_obj_users[og].insert(ou); | ||
| 436 | + } else { | ||
| 437 | + t_object_to_obj_users[QPDFObjGen(i2, 0)].insert(ou); | ||
| 438 | + } | ||
| 435 | } | 439 | } |
| 436 | } | 440 | } |
| 437 | } | 441 | } |
libqpdf/qpdf/ObjTable.hh
| @@ -63,6 +63,12 @@ class ObjTable: public std::vector<T> | @@ -63,6 +63,12 @@ class ObjTable: public std::vector<T> | ||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | inline bool | 65 | inline bool |
| 66 | + contains(QPDFObjGen og) const | ||
| 67 | + { | ||
| 68 | + return contains(static_cast<size_t>(og.getObj())); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + inline bool | ||
| 66 | contains(QPDFObjectHandle oh) const | 72 | contains(QPDFObjectHandle oh) const |
| 67 | { | 73 | { |
| 68 | return contains(static_cast<size_t>(oh.getObjectID())); | 74 | return contains(static_cast<size_t>(oh.getObjectID())); |