lib/fuzzing: Link only the required NDR_ subsystems into ndr_fuzz_X binaries
authorAndrew Bartlett <abartlet@samba.org>
Thu, 28 Nov 2019 23:07:34 +0000 (12:07 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 10 Dec 2019 07:50:28 +0000 (07:50 +0000)
This reduces the binary size and shows that we are linked against the correct
ndr_table_ global variable.  This might help the fuzzing engine know there
is not much more of the binary to find if unreachable code is not included.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
buildtools/wafsamba/samba_pidl.py
lib/fuzzing/wscript_build

index 8785563e5e639c708edf9e39a1c3effe967e7462..b92120edd23fbe8e65381160b48c21df7bab5b13 100644 (file)
@@ -123,7 +123,7 @@ def SAMBA_PIDL_LIST(bld, name, source,
         # the fuzzers rely
         if generate_tables and generate_fuzzers:
             interface = p[0:-4] # strip off the .idl suffix
-            bld.SAMBA_NDR_FUZZ(interface)
+            bld.SAMBA_NDR_FUZZ(interface, auto_deps=True)
 Build.BuildContext.SAMBA_PIDL_LIST = SAMBA_PIDL_LIST
 
 
index 25cdcd323bf9b372f54280ab0979c926ebb67244..60a94cea814fef1350473bea431b9b07b35430aa 100644 (file)
@@ -43,7 +43,7 @@ bld.SAMBA_BINARY('fuzz_ldb_parse_tree',
                  deps='fuzzing ldb',
                  fuzzer=True)
 
-def SAMBA_NDR_FUZZ(bld, interface):
+def SAMBA_NDR_FUZZ(bld, interface, auto_deps=False):
     name = "fuzz_ndr_%s" % (interface.lower())
     fuzz_dir = os.path.join(bld.env.srcdir, 'lib/fuzzing')
     fuzz_reldir = os.path.relpath(fuzz_dir, bld.path.abspath())
@@ -59,9 +59,14 @@ def SAMBA_NDR_FUZZ(bld, interface):
                         target=fuzz_named_src,
                         rule='cp ${SRC} ${TGT}')
 
+    if auto_deps:
+        deps = "talloc ndr NDR_%s" % interface.upper()
+    else:
+        deps = "ndr-table NDR_DCERPC"
+
     bld.SAMBA_BINARY(name, source=fuzz_named_src,
                      cflags = "-D FUZZ_PIPE_TABLE=ndr_table_%s" % interface,
-                     deps = "ndr-table NDR_DCERPC",
+                     deps = deps,
                      install=False,
                      fuzzer=True)