From cc460242f0fca8028cc4727c69d50e7b58725f51 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 1 Nov 2023 21:24:38 +0000 Subject: [PATCH] Move oss-fuzz build script to the repo --- Tests/Fuzzers/default.options | 2 ++ Tests/Fuzzers/ossfuzz.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Tests/Fuzzers/default.options create mode 100755 Tests/Fuzzers/ossfuzz.sh diff --git a/Tests/Fuzzers/default.options b/Tests/Fuzzers/default.options new file mode 100644 index 0000000000..eb7fde2c61 --- /dev/null +++ b/Tests/Fuzzers/default.options @@ -0,0 +1,2 @@ +[libfuzzer] +close_fd_mask=3 diff --git a/Tests/Fuzzers/ossfuzz.sh b/Tests/Fuzzers/ossfuzz.sh new file mode 100755 index 0000000000..a067c711c3 --- /dev/null +++ b/Tests/Fuzzers/ossfuzz.sh @@ -0,0 +1,34 @@ +TARGETS_DIR=build/ + +# Build libpcap +cd $SRC/libpcap/ +./autogen.sh +./configure --enable-shared=no +make -j$(nproc) + +# Build PcapPlusPlus linking statically against the built libpcap +cd $SRC/PcapPlusPlus +LIBPCAP_PATH=$SRC/libpcap/ +cmake -DPCAPPP_BUILD_FUZZERS=ON -DPCAPPP_BUILD_TESTS=OFF -DPCAPPP_BUILD_EXAMPLES=OFF -DPCAP_INCLUDE_DIR="${LIBPCAP_PATH}/" -DPCAP_LIBRARY="${LIBPCAP_PATH}/libpcap.a" -S . -B $TARGETS_DIR +cmake --build $TARGETS_DIR -j + +# Copy target and options +FUZZERS=" + FuzzTarget \ + FuzzTargetNg \ + FuzzTargetSnoop \ + FuzzWriter \ + FuzzWriterNg" + +for fuzzer in $FUZZERS; do + cp $TARGETS_DIR/Tests/Fuzzers/${fuzzer} $OUT + cp $(ldd $OUT/${fuzzer} | cut -d" " -f3) $OUT + cp Tests/Fuzzers/default.options $OUT/${fuzzer}.options +done + +# Copy corpora +find $SRC/ -iname "*.pcap" | xargs zip $OUT/FuzzTarget_seed_corpus.zip +find $SRC/ -iname "*.pcapng" | xargs zip $OUT/FuzzTargetNg_seed_corpus.zip +find $SRC/ -iname "*.snoop" | xargs zip $OUT/FuzzTargetSnoop_seed_corpus.zip +find $SRC/ -iname "*.pcap" | xargs zip $OUT/FuzzWriter_seed_corpus.zip +find $SRC/ -iname "*.pcapng" | xargs zip $OUT/FuzzWriterNg_seed_corpus.zip