summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
authorMichael Hanselmann <public@hansmi.ch>2019-04-04 00:23:07 +0200
committerAndrew Bartlett <abartlet@samba.org>2019-08-07 06:07:28 +0000
commitdd5f8732d8b2ac6cd86e5d7dc8a9498d2b951a43 (patch)
tree543610a4c04c3a6be9094e1ea3573cee7f52284d /buildtools
parentaab17124785b6e4c004368b69bee28fb6cad55c3 (diff)
downloadsamba-dd5f8732d8b2ac6cd86e5d7dc8a9498d2b951a43.tar.gz
Add fuzzing support to build system
LibFuzzer, Honggfuzz and other programs implement simple interfaces for fuzzing appropriately prepared code. Samba contains quite a lot of parsing code, often a good target for fuzzing. With this change the build system is amended to support building fuzzing binaries (added in later changes). Signed-off-by: Michael Hanselmann <public@hansmi.ch> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/wafsamba/samba_autoconf.py5
-rw-r--r--buildtools/wafsamba/wscript7
2 files changed, 12 insertions, 0 deletions
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 352b5ca31d3..ee15e34b5ec 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -938,6 +938,11 @@ def SETUP_CONFIGURE_CACHE(conf, enable):
@conf
def SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS(conf):
+ if Options.options.address_sanitizer or Options.options.enable_libfuzzer:
+ # Sanitizers can rely on symbols undefined at library link time and the
+ # symbols used for fuzzers are only defined by compiler wrappers.
+ return
+
if not sys.platform.startswith("openbsd"):
# we don't want any libraries or modules to rely on runtime
# resolution of symbols
diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index e5017a4a02f..ce5e0b48fc1 100644
--- a/buildtools/wafsamba/wscript
+++ b/buildtools/wafsamba/wscript
@@ -129,6 +129,9 @@ def options(opt):
action="store_true",
dest='undefined_sanitizer',
default=False)
+ gr.add_option('--enable-libfuzzer',
+ help=("Build fuzzing binaries (requires compiler options for libFuzzer or compiler wrapper such as honggfuzz/hfuzz-cc)"),
+ action="store_true", dest='enable_libfuzzer', default=False)
gr.add_option('--abi-check',
help=("Check ABI signatures for libraries"),
@@ -590,6 +593,10 @@ struct foo bar = { .y = 'X', .x = 1 };
eprintf("bla", "bar")
''', define='HAVE__VA_ARGS__MACRO')
+ conf.env.enable_libfuzzer = Options.options.enable_libfuzzer
+ if conf.env.enable_libfuzzer:
+ conf.DEFINE('ENABLE_LIBFUZZER', 1)
+
conf.SAMBA_BUILD_ENV()