From: Tobias Brunner Date: Wed, 17 Jul 2019 09:16:19 +0000 (+0200) Subject: fuzz: Support build with -fsanitize=fuzzer instead of libFuzzer.a X-Git-Tag: 5.8.1rc1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05e3751ebb80110dff3a9c02155431d7d6e31111;p=thirdparty%2Fstrongswan.git 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. --- diff --git a/configure.ac b/configure.ac index 186202a830..5dc1ae232f 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am index df228d38b1..de0a2604dd 100644 --- a/fuzz/Makefile.am +++ b/fuzz/Makefile.am @@ -1,4 +1,5 @@ AM_CPPFLAGS = @CPPFLAGS@ \ + @FUZZING_CFLAGS@ \ -I$(top_srcdir)/src/libstrongswan \ -I$(top_srcdir)/src/libimcv \ -I$(top_srcdir)/src/libtncif \