Commit c1cd3ec8a03ef81a43f6c3de8135dff351adbdf5
1 parent
ce2deaf1
In QPDF::processXRefIndex check number of objects in subsection is > 0
Fixes oss-fuzz 70055
Showing
4 changed files
with
7 additions
and
1 deletions
fuzz/CMakeLists.txt
| @@ -122,6 +122,7 @@ set(CORPUS_OTHER | @@ -122,6 +122,7 @@ set(CORPUS_OTHER | ||
| 122 | 69913.fuzz | 122 | 69913.fuzz |
| 123 | 69969.fuzz | 123 | 69969.fuzz |
| 124 | 69977.fuzz | 124 | 69977.fuzz |
| 125 | + 70055.fuzz | ||
| 125 | ) | 126 | ) |
| 126 | 127 | ||
| 127 | set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus) | 128 | set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus) |
fuzz/qpdf_extra/70055.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' => 64], # increment when adding new files | 24 | + ['qpdf' => 65], # increment when adding new files |
| 25 | ); | 25 | ); |
| 26 | 26 | ||
| 27 | my $n_tests = 0; | 27 | my $n_tests = 0; |
libqpdf/QPDF.cc
| @@ -1129,6 +1129,11 @@ QPDF::processXRefIndex( | @@ -1129,6 +1129,11 @@ QPDF::processXRefIndex( | ||
| 1129 | if (val.isInteger()) { | 1129 | if (val.isInteger()) { |
| 1130 | if (i % 2) { | 1130 | if (i % 2) { |
| 1131 | auto count = val.getIntValue(); | 1131 | auto count = val.getIntValue(); |
| 1132 | + if (count <= 0) { | ||
| 1133 | + throw damaged( | ||
| 1134 | + "Cross-reference stream section claims to contain " + | ||
| 1135 | + std::to_string(count) + " entries"); | ||
| 1136 | + } | ||
| 1132 | // We are guarding against the possibility of num_entries * entry_size | 1137 | // We are guarding against the possibility of num_entries * entry_size |
| 1133 | // overflowing. We are not checking that entries are in ascending order as | 1138 | // overflowing. We are not checking that entries are in ascending order as |
| 1134 | // required by the spec, which probably should generate a warning. We are also | 1139 | // required by the spec, which probably should generate a warning. We are also |