Skip to content

Commit

Permalink
Move oss-fuzz build script to the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
sashashura committed Nov 3, 2023
1 parent 49b0b20 commit cc62f9f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Tests/Fuzzers/default.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libfuzzer]
close_fd_mask=3
34 changes: 34 additions & 0 deletions Tests/Fuzzers/ossfuzz.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cc62f9f

Please sign in to comment.