]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
fuzz: enable fuzzer target in afl examples and add missing script [ci skip]
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 21 Feb 2018 10:21:36 +0000 (11:21 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 21 Feb 2018 10:41:55 +0000 (11:41 +0100)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
fuzz/README.md
fuzz/run-afl.sh [new file with mode: 0755]

index 36e4e504e90326cbe1eb8aa90e9ffde9dd9f69c8..1fc737ed583cc10c1f704d54ccedf35df648dfb1 100644 (file)
@@ -32,7 +32,7 @@ UBSAN_OPTIONS=print_stacktrace=1 ASAN_SYMBOLIZER_PATH=/usr/lib/llvm-5.0/bin/llvm
 Use the following commands on top dir:
 
 ```
-$ CC=afl-clang-fast ./configure --disable-doc
+$ CC=afl-clang-fast ./configure --disable-doc --enable-fuzzer-target --disable-guile
 $ make -j$(nproc) clean all
 $ cd fuzz
 $ ./run-afl.sh gnutls_base64_decoder_fuzzer
@@ -43,7 +43,7 @@ $ ./run-afl.sh gnutls_base64_decoder_fuzzer
 Use the following commands on top dir:
 
 ```
-$ CC=afl-gcc ./configure --disable-doc
+$ CC=afl-gcc ./configure --disable-doc --enable-fuzzer-target --disable-guile
 $ make -j$(nproc) clean all
 $ cd fuzz
 $ ./run-afl.sh gnutls_base64_decoder_fuzzer
diff --git a/fuzz/run-afl.sh b/fuzz/run-afl.sh
new file mode 100755 (executable)
index 0000000..9daaf60
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+# Copyright (C) 2017 Red Hat, Inc.
+#
+# This file is part of GnuTLS.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>
+
+srcdir="${srcdir:-.}"
+export LD_LIBRARY_PATH=${srcdir}/../lib/.libs/
+
+cat ${srcdir}/../config.log|grep afl-gcc >/dev/null 2>&1
+if test $? != 0;then
+       echo "compile first library as:"
+       echo "CC=afl-gcc ./configure"
+       exit 1
+else
+       fuzz=afl-gcc
+fi
+
+if test -z "$1";then
+       echo "Usage: $0 test-case"
+       echo "Example: $0 gnutls_x509_parser_fuzzer"
+       exit 1
+fi
+
+TEST=$1
+rm -f ${TEST}
+export LD_LIBRARY_PATH=$(pwd)/../lib/.libs/
+export CFLAGS="-g -O2 -I/usr/local/include -I../lib/includes -I.."
+${fuzz} ${CFLAGS} -o ${TEST} main.c ${TEST}.c -L../lib/.libs/ -lgnutls || exit 1
+
+TMPOUT=${TEST}.$$.out
+mkdir -p ${TMPOUT}
+afl-fuzz -i ${TEST}.in -o ${TMPOUT} -- ./${TEST}
+
+echo "output was stored in $TMPOUT"
+
+exit 0