]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
fuzz: Support build with -fsanitize=fuzzer instead of libFuzzer.a
authorTobias Brunner <tobias@strongswan.org>
Wed, 17 Jul 2019 09:16:19 +0000 (11:16 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 17 Jul 2019 09:44:27 +0000 (11:44 +0200)
Recent clang versions (6.0+) include libFuzzer and OSS-Fuzz switched to
that mode a while ago.

configure.ac
fuzz/Makefile.am

index 186202a83043526905eb230335d2c80b2bd1e225..5dc1ae232fa0d8e8ca640a855c180c3da6d06a9b 100644 (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
index df228d38b1e6eec2bc6820a945294e1f89b751e1..de0a2604dd717313288c2e0d64582230e3e9ecfc 100644 (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 \