]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
configure: Add --with-fuzzer=clang to use clang fuzzer
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 23 Mar 2020 16:28:34 +0000 (18:28 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 8 Jan 2021 14:53:44 +0000 (14:53 +0000)
configure.ac
m4/dovecot.m4

index aa6e9e644166755a9d396d9ce94bfba988e2f5d4..ae1771794854d0707cb3ff32fe44931f99638786 100644 (file)
@@ -310,6 +310,7 @@ AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h malloc.h \
 CC_CLANG
 AC_LD_WHOLE_ARCHIVE
 DC_DOVECOT_HARDENING
+DC_DOVECOT_FUZZER
 DC_DOVECOT_CFLAGS
 
 DOVECOT_NSL
index 2b5d8957e5c317fe305d8d21ac19fea22f17f524..02bdd406a162cf4993ac81846350cae87f4a0a10 100644 (file)
@@ -335,6 +335,27 @@ AC_DEFUN([DC_DOVECOT_HARDENING],[
        DOVECOT_WANT_UBSAN
 ])
 
+AC_DEFUN([DC_DOVECOT_FUZZER],[
+        AC_ARG_WITH(fuzzer,
+        AS_HELP_STRING([--with-fuzzer=clang], [Build with clang fuzzer (default: no)]),
+                with_fuzzer=$withval,
+                with_fuzzer=no)
+       AS_IF([test x$with_fuzzer = xclang], [
+               CFLAGS="$CFLAGS -fsanitize=fuzzer-no-link"
+               # use $LIB_FUZZING_ENGINE for linking if it exists
+               FUZZER_LDFLAGS=${LIB_FUZZING_ENGINE--fsanitize=fuzzer}
+               # May need to use CXXLINK for linking, which wants sources to
+               # be compiled with -fPIE
+               FUZZER_CPPFLAGS='$(AM_CPPFLAGS) -fPIE -DPIE'
+       ], [test x$with_fuzzer != xno], [
+               AC_MSG_ERROR([Unknown fuzzer $with_fuzzer])
+       ])
+       AC_SUBST([FUZZER_CPPFLAGS])
+       AC_SUBST([FUZZER_LDFLAGS])
+       AM_CONDITIONAL([USE_FUZZER], [test "x$with_fuzzer" != "xno"])
+
+])
+
 AC_DEFUN([DC_DOVECOT],[
        AC_ARG_WITH(dovecot,
          [  --with-dovecot=DIR      Dovecot base directory],