@@ -1,6 +1,6 @@
11# Script based on code from https://github.com/ndmitchell/hexml/issues/6
22# More examples of things to do are at that ticket
3−set -eu
3+set -e
44
55# First install AFL
66if ! command -v afl-clang-fast > /dev/null ; then
@@ -21,8 +21,13 @@ AFL_HARDEN=1 afl-clang-fast -O2 -Icbits cbits/fuzz.c -o $PWD/hexml-fuzz
2121if ! grep -q core /proc/sys/kernel/core_pattern ; then
2222 echo core | sudo tee /proc/sys/kernel/core_pattern
2323fi
24−AFL_EXIT_WHEN_DONE=1 AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so afl-fuzz -T hexml -x /usr/local/share/afl/dictionaries/xml.dict -i $PWD/xml -o $PWD/afl-results -- $PWD/hexml-fuzz @@
25−cat afl-results/fuzzer_stats
24+if [ -z "$CI" ] ; then
25+ AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so afl-fuzz -T hexml -x /usr/local/share/afl/dictionaries/xml.dict -i $PWD/xml -o $PWD/afl-results -- $PWD/hexml-fuzz @@
26+else
27+ AFL_EXIT_WHEN_DONE=1 AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so timeout 5m afl-fuzz -T hexml -x /usr/local/share/afl/dictionaries/xml.dict -i $PWD/xml -o $PWD/afl-results -- $PWD/hexml-fuzz @@ > /dev/null || true
28+ cat afl-results/fuzzer_stats
29+ grep "unique_crashes *: 0" afl-results/fuzzer_stats # fail if there are failures
30+fi
2631
2732# Minimize failures
2833# $ AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so afl-cmin -i results/crashes/ -o results.shrunk -- $PWD/a.out @@