diff options
Diffstat (limited to 'fuzz')
| -rw-r--r-- | fuzz/Makefile.am | 36 | ||||
| -rwxr-xr-x | fuzz/fuzzers.test | 8 | ||||
| -rwxr-xr-x | fuzz/init-fuzzers.sh | 23 | ||||
| -rwxr-xr-x | fuzz/test-fuzzers.sh | 33 |
4 files changed, 100 insertions, 0 deletions
diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am new file mode 100644 index 0000000..b9798f9 --- /dev/null +++ b/fuzz/Makefile.am | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | if BUILD_FUZZERS | ||
| 2 | |||
| 3 | libFuzzer.a: Fuzzer/build.sh | ||
| 4 | @echo "Building $@" | ||
| 5 | @./Fuzzer/build.sh | ||
| 6 | |||
| 7 | Fuzzer/build.sh: LIBFUZZER_SRC | ||
| 8 | |||
| 9 | LIBFUZZER_SRC: | ||
| 10 | @if test -d Fuzzer ; then \ | ||
| 11 | if test -d Fuzzer/.git ; then \ | ||
| 12 | echo Making sure libFuzzer source tree is up-to-date... ; \ | ||
| 13 | cd Fuzzer && git checkout . && git pull && cd .. ; \ | ||
| 14 | fi \ | ||
| 15 | else \ | ||
| 16 | echo Checking out libFuzzer source code... ; \ | ||
| 17 | git clone https://chromium.googlesource.com/chromium/llvm-project/llvm/lib/Fuzzer ; \ | ||
| 18 | fi | ||
| 19 | |||
| 20 | CLEANFILES = libFuzzer.a | ||
| 21 | |||
| 22 | noinst_PROGRAMS = xplist_fuzzer bplist_fuzzer | ||
| 23 | |||
| 24 | xplist_fuzzer_SOURCES = xplist_fuzzer.cc | ||
| 25 | xplist_fuzzer_LDFLAGS = -static | ||
| 26 | xplist_fuzzer_LDADD = $(top_builddir)/src/libplist.la libFuzzer.a | ||
| 27 | |||
| 28 | bplist_fuzzer_SOURCES = bplist_fuzzer.cc | ||
| 29 | bplist_fuzzer_LDFLAGS = -static | ||
| 30 | bplist_fuzzer_LDADD = $(top_builddir)/src/libplist.la libFuzzer.a | ||
| 31 | |||
| 32 | TESTS = fuzzers.test | ||
| 33 | |||
| 34 | EXTRA_DIST = bplist.dict xplist.dict init-fuzzers.sh test-fuzzers.sh fuzzers.test | ||
| 35 | |||
| 36 | endif | ||
diff --git a/fuzz/fuzzers.test b/fuzz/fuzzers.test new file mode 100755 index 0000000..dd3fb08 --- /dev/null +++ b/fuzz/fuzzers.test | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | ## -*- sh -*- | ||
| 2 | |||
| 3 | set -e | ||
| 4 | |||
| 5 | ./init-fuzzers.sh | ||
| 6 | |||
| 7 | ./test-fuzzers.sh | ||
| 8 | |||
diff --git a/fuzz/init-fuzzers.sh b/fuzz/init-fuzzers.sh new file mode 100755 index 0000000..e48baa8 --- /dev/null +++ b/fuzz/init-fuzzers.sh | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | CURDIR=`pwd` | ||
| 4 | FUZZDIR=`dirname $0` | ||
| 5 | |||
| 6 | cd ${FUZZDIR} | ||
| 7 | |||
| 8 | if ! test -x xplist_fuzzer || ! test -x bplist_fuzzer; then | ||
| 9 | echo "ERROR: you need to build the fuzzers first." | ||
| 10 | cd ${CURDIR} | ||
| 11 | exit 1 | ||
| 12 | fi | ||
| 13 | |||
| 14 | mkdir -p xplist-input | ||
| 15 | cp ../test/data/*.plist xplist-input/ | ||
| 16 | ./xplist_fuzzer -merge=1 xplist-input crashes leaks -dict=xplist.dict | ||
| 17 | |||
| 18 | mkdir -p bplist-input | ||
| 19 | cp ../test/data/*.bplist bplist-input/ | ||
| 20 | ./bplist_fuzzer -merge=1 bplist-input crashes leaks -dict=bplist.dict | ||
| 21 | |||
| 22 | cd ${CURDIR} | ||
| 23 | exit 0 | ||
diff --git a/fuzz/test-fuzzers.sh b/fuzz/test-fuzzers.sh new file mode 100755 index 0000000..5c758c4 --- /dev/null +++ b/fuzz/test-fuzzers.sh | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | CURDIR=`pwd` | ||
| 4 | FUZZDIR=`dirname $0` | ||
| 5 | |||
| 6 | cd ${FUZZDIR} | ||
| 7 | |||
| 8 | if ! test -x xplist_fuzzer || ! test -x bplist_fuzzer; then | ||
| 9 | echo "ERROR: you need to build the fuzzers first." | ||
| 10 | cd ${CURDIR} | ||
| 11 | exit 1 | ||
| 12 | fi | ||
| 13 | |||
| 14 | if ! test -d xplist-input || ! test -d bplist-input; then | ||
| 15 | echo "ERROR: fuzzer corpora directories are not present. Did you run init-fuzzers.sh ?" | ||
| 16 | cd ${CURDIR} | ||
| 17 | exit 1 | ||
| 18 | fi | ||
| 19 | |||
| 20 | echo "### TESTING xplist_fuzzer ###" | ||
| 21 | if ! ./xplist_fuzzer xplist-input -dict=xplist.dict -runs=10000; then | ||
| 22 | cd ${CURDIR} | ||
| 23 | exit 1 | ||
| 24 | fi | ||
| 25 | |||
| 26 | echo "### TESTING bplist_fuzzer ###" | ||
| 27 | if ! ./bplist_fuzzer bplist-input -dict=bplist.dict -runs=10000; then | ||
| 28 | cd ${CURDIR} | ||
| 29 | exit 1 | ||
| 30 | fi | ||
| 31 | |||
| 32 | cd ${CURDIR} | ||
| 33 | exit 0 | ||
