fuzz: Support build with -fsanitize=fuzzer instead of libFuzzer.a

Recent clang versions (6.0+) include libFuzzer and OSS-Fuzz switched to
that mode a while ago.
This commit is contained in:
Tobias Brunner 2019-07-17 11:16:19 +02:00
parent de07b77442
commit 05e3751ebb
2 changed files with 13 additions and 4 deletions

View File

@ -63,7 +63,7 @@ ARG_WITH_SUBST([routing-table], [220], [set routing table to use for IPsec
ARG_WITH_SUBST([routing-table-prio], [220], [set priority for IPsec routing table])
ARG_WITH_SUBST([ipsec-script], [ipsec], [change the name of the ipsec script])
ARG_WITH_SUBST([fips-mode], [0], [set openssl FIPS mode: disabled(0), enabled(1), Suite B enabled(2)])
ARG_WITH_SUBST([libfuzzer], [], [path to libFuzzer.a])
ARG_WITH_SUBST([libfuzzer], [], [-fsanitize=fuzzer or path to libFuzzer.a, a local driver is used if not specified])
ARG_WITH_SET([capabilities], [no], [set capability dropping library. Currently supported values are "libcap" and "native"])
ARG_WITH_SET([mpz_powm_sec], [yes], [use the more side-channel resistant mpz_powm_sec in libgmp, if available])
ARG_WITH_SET([dev-headers], [no], [install strongSwan development headers to directory.])
@ -1294,18 +1294,26 @@ if test x$coverage = xtrue; then
fi
if test x$fuzzing = xtrue; then
if test x$libfuzzer = x; then
case "$libfuzzer" in
"")
AC_MSG_NOTICE([fuzz targets enabled without libFuzzer, using local driver])
CFLAGS="${CFLAGS} -fsanitize=address"
libfuzzer="libFuzzerLocal.a"
else
;;
"-fsanitize=fuzzer")
libfuzzer=""
FUZZING_CFLAGS="-fsanitize=fuzzer"
AC_SUBST(FUZZING_CFLAGS)
;;
*)
# required for libFuzzer
FUZZING_LDFLAGS="-stdlib=libc++ -lstdc++"
if test "$SANITIZER" = "coverage"; then
FUZZING_LDFLAGS="$FUZZING_LDFLAGS -lm"
fi
AC_SUBST(FUZZING_LDFLAGS)
fi
;;
esac
fi
if test x$ruby_gems = xtrue; then

View File

@ -1,4 +1,5 @@
AM_CPPFLAGS = @CPPFLAGS@ \
@FUZZING_CFLAGS@ \
-I$(top_srcdir)/src/libstrongswan \
-I$(top_srcdir)/src/libimcv \
-I$(top_srcdir)/src/libtncif \