From f21a39496d0b68a499ee9680cf472ac30a41175a Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 26 Apr 2019 09:59:01 +0200 Subject: [PATCH] add script to minimize corpus --- docs/fuzzing.rst | 7 +++++++ docs/hunspell/libtorrent.dic | 1 + fuzzers/Jamfile | 1 + fuzzers/minimize.sh | 17 +++++++++++++++++ fuzzers/run.sh | 28 ++++------------------------ 5 files changed, 30 insertions(+), 24 deletions(-) create mode 100755 fuzzers/minimize.sh diff --git a/docs/fuzzing.rst b/docs/fuzzing.rst index f60c7c3eb..215efae45 100644 --- a/docs/fuzzing.rst +++ b/docs/fuzzing.rst @@ -75,3 +75,10 @@ large fuzz targets. Call `b2` like this:: b2 clang stage-large -j$(nproc) +sharing corpora +--------------- + +Before sharing your fuzz corpus, it should be minimized. There is a script +called `minimize.sh` which moves `corpus` to `prev-corpus` and copies over +a minimized set of inputs to a new `corpus` directory. + diff --git a/docs/hunspell/libtorrent.dic b/docs/hunspell/libtorrent.dic index c6c4c2789..c182b1128 100644 --- a/docs/hunspell/libtorrent.dic +++ b/docs/hunspell/libtorrent.dic @@ -468,3 +468,4 @@ fuzzers fuzzer libFuzzer clang's +prev diff --git a/fuzzers/Jamfile b/fuzzers/Jamfile index df700a723..765b0550c 100644 --- a/fuzzers/Jamfile +++ b/fuzzers/Jamfile @@ -76,6 +76,7 @@ local LARGE_TARGETS = resume_data file_storage_add_file sanitize_path + upnp ; install stage : $(TARGETS) : EXE fuzzers ; diff --git a/fuzzers/minimize.sh b/fuzzers/minimize.sh new file mode 100755 index 000000000..802d868a8 --- /dev/null +++ b/fuzzers/minimize.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +function minimize +{ +mkdir corpus/${1} +./fuzzers/${1} -artifact_prefix=./${1}- -merge=1 corpus/${1} prev-corpus/${1} +} + +mv corpus prev-corpus +mkdir corpus + +for file in fuzzers/*; do + minimize $(basename $file) & +done + +wait + diff --git a/fuzzers/run.sh b/fuzzers/run.sh index e966ffcfd..639011be6 100755 --- a/fuzzers/run.sh +++ b/fuzzers/run.sh @@ -1,3 +1,4 @@ +#!/bin/bash function run { @@ -5,29 +6,8 @@ function run ./fuzzers/${1} -max_total_time=172800 -timeout=10 -artifact_prefix=./${1}- corpus/${1} } -run torrent_info & -run parse_magnet_uri & -run bdecode_node & -run lazy_bdecode & -run parse_int & -run sanitize_path & -run escape_path & -run file_storage_add_file & -run base32decode & -run base32encode & -run base64encode & -run escape_string e& -run gzip & -run verify_encoding & -run convert_to_native & -run convert_from_native & -run utf8_wchar & -run wchar_utf8 & -run utf8_codepoint & -run http_parser & -run upnp & -run dht_node & -run utp & -run resume_data & +for file in fuzzers/*; do + run $(basename $file) & +done wait