Commit 42c511198b34b247cb43f0a26b3a518c6e060216

Authored by m-holger
1 parent 9081ac69

Suppress excessive warnings while fuzzing

Add extra fuzz test case and amend memory limit for Pl_DCT.
fuzz/CMakeLists.txt
@@ -121,6 +121,7 @@ set(CORPUS_OTHER @@ -121,6 +121,7 @@ set(CORPUS_OTHER
121 69857.fuzz 121 69857.fuzz
122 69913.fuzz 122 69913.fuzz
123 69969.fuzz 123 69969.fuzz
  124 + 69977.fuzz
124 ) 125 )
125 126
126 set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus) 127 set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus)
fuzz/qpdf_extra/69977.fuzz 0 → 100644
No preview for this file type
fuzz/qpdf_fuzzer.cc
@@ -173,11 +173,11 @@ FuzzHelper::doChecks() @@ -173,11 +173,11 @@ FuzzHelper::doChecks()
173 { 173 {
174 // Get as much coverage as possible in parts of the library that 174 // Get as much coverage as possible in parts of the library that
175 // might benefit from fuzzing. 175 // might benefit from fuzzing.
176 - std::cout << "starting testWrite\n"; 176 + std::cerr << "\ninfo: starting testWrite\n";
177 testWrite(); 177 testWrite();
178 - std::cout << "\nstarting testPages\n\n"; 178 + std::cerr << "\ninfo: starting testPages\n";
179 testPages(); 179 testPages();
180 - std::cout << "\nstarting testOutlines\n\n"; 180 + std::cerr << "\ninfo: starting testOutlines\n";
181 testOutlines(); 181 testOutlines();
182 } 182 }
183 183
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' => 63], # increment when adding new files 24 + ['qpdf' => 64], # increment when adding new files
25 ); 25 );
26 26
27 my $n_tests = 0; 27 my $n_tests = 0;
libqpdf/Pl_DCT.cc
@@ -320,7 +320,7 @@ Pl_DCT::decompress(void* cinfo_p, Buffer* b) @@ -320,7 +320,7 @@ Pl_DCT::decompress(void* cinfo_p, Buffer* b)
320 cinfo->mem->max_memory_to_use = 1'000'000'000; 320 cinfo->mem->max_memory_to_use = 1'000'000'000;
321 // For some corrupt files the memory used internally by libjpeg stays within the above limits 321 // For some corrupt files the memory used internally by libjpeg stays within the above limits
322 // even though the size written to the next pipeline is significantly larger. 322 // even though the size written to the next pipeline is significantly larger.
323 - m->corrupt_data_limit = 100'000'000; 323 + m->corrupt_data_limit = 10'000'000;
324 #endif 324 #endif
325 jpeg_buffer_src(cinfo, b); 325 jpeg_buffer_src(cinfo, b);
326 326
libqpdf/QPDF.cc
@@ -494,6 +494,13 @@ QPDF::warn(QPDFExc const&amp; e) @@ -494,6 +494,13 @@ QPDF::warn(QPDFExc const&amp; e)
494 { 494 {
495 m->warnings.push_back(e); 495 m->warnings.push_back(e);
496 if (!m->suppress_warnings) { 496 if (!m->suppress_warnings) {
  497 +#ifdef QPDF_OSS_FUZZ
  498 + if (m->warnings.size() > 20) {
  499 + *m->log->getWarn() << "WARNING: too many warnings - additional warnings surpressed\n";
  500 + m->suppress_warnings = true;
  501 + return;
  502 + }
  503 +#endif
497 *m->log->getWarn() << "WARNING: " << m->warnings.back().what() << "\n"; 504 *m->log->getWarn() << "WARNING: " << m->warnings.back().what() << "\n";
498 } 505 }
499 } 506 }