aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--fuzz/qtest/fuzz.test52
-rw-r--r--qpdf/qtest/qpdf.test2
3 files changed, 58 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 8260c2bb..07a2ec30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2019-06-15 Jay Berkenbilt <ejb@ql.org>
+ * Do "ideal integration" with oss-fuzz. This includes adding a
+ better fuzzer with a seed corpus and adding automated tests of the
+ fuzzer with the test data.
+
* When parsing files, while reading an object, if there are too
many consecutive errors without enough intervening successes, give
up on the specific object. This reduces cases in which very badly
diff --git a/fuzz/qtest/fuzz.test b/fuzz/qtest/fuzz.test
new file mode 100644
index 00000000..d359a573
--- /dev/null
+++ b/fuzz/qtest/fuzz.test
@@ -0,0 +1,52 @@
+#!/usr/bin/env perl
+require 5.008;
+use warnings;
+use strict;
+use Digest::SHA;
+use File::Basename;
+
+require TestDriver;
+
+my $td = new TestDriver('fuzz');
+
+if (($^O eq 'MSWin32') || ($^O eq 'msys'))
+{
+ $td->emphasize("temporarily skipping fuzz tests in Windows");
+ $td->report(0);
+ exit(0);
+}
+
+my @files = glob("../qpdf_fuzzer_seed_corpus/*");
+my $n_test_files = 27;
+my $n_orig_files = 2559;
+my $n_files = $n_test_files + $n_orig_files;
+
+if (scalar(@files) != $n_files)
+{
+ die "wrong number of files seen in fuzz.test";
+}
+
+foreach my $f (@files)
+{
+ my $sum = basename($f);
+ $td->runtest("checksum $sum",
+ {$td->STRING => get_sha1_checksum($f)},
+ {$td->STRING => $sum});
+ $td->runtest("fuzz check $sum",
+ {$td->COMMAND => "qpdf_fuzzer $f"},
+ {$td->REGEXP => ".*$f successful\n",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+}
+
+$td->report(2 * $n_files);
+
+sub get_sha1_checksum
+{
+ my $file = shift;
+ open(F, "<$file") or fatal("can't open $file: $!");
+ binmode F;
+ my $digest = Digest::SHA->new('sha1')->addfile(*F)->hexdigest;
+ close(F);
+ $digest;
+}
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index c6b88320..eb2af1a4 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -642,6 +642,8 @@ my @bug_tests = (
["263", "empty xref stream", 2],
["335a", "ozz-fuzz-12152", 2],
["335b", "ozz-fuzz-14845", 2],
+ # When adding to this list, consider adding to SEED_CORPUS_FILES
+ # in fuzz/build.mk and updating the count in fuzz/qtest/fuzz.test.
);
$n_tests += scalar(@bug_tests);
foreach my $d (@bug_tests)