]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
create protocol-specific fuzzers
authorAlan T. DeKok <aland@freeradius.org>
Mon, 28 Oct 2019 12:32:16 +0000 (08:32 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 28 Oct 2019 12:33:51 +0000 (08:33 -0400)
src/bin/.gitignore
src/bin/all.mk
src/bin/fuzzer.mk

index 65f5051f470c93d6e78c8cff2d69dbb9776f0e9f..78bb33ea7001e7965a2ec90c39b789290d84c82c 100644 (file)
@@ -1,3 +1,4 @@
 checkrad
 radlast
 radtest
+fuzzer_radius.mk
index 13515a3371e3682cbdeb4b07c0ac4482760229fc..b13bd40bb9432e5fd502dfc1cb6788a089c8eb43 100644 (file)
@@ -17,5 +17,24 @@ SUBMAKEFILES := \
 #  Add the fuzzer only if everything was built with the fuzzing flags.
 #
 ifneq "$(findstring -fsanitize=fuzzer,${CFLAGS})" ""
-SUBMAKEFILES += fuzzer.mk
+
+#
+#  Define a function to do all of the same thing.
+#
+define FUZZ_PROTOCOL
+src/bin/fuzzer_${1}.mk: src/bin/fuzzer.mk
+       $${Q}echo "PROTOCOL=${1}" > $$@
+       $${Q}cat $$^ >> $$@
+
+SUBMAKEFILES += fuzzer_${1}.mk
+endef
+
+#
+#  Add the list of protocols to be fuzzed here Each protocol needs to
+#  have a test point for packet decoding.  See
+#  src/protocols/radius/decode.c for an example.
+#
+PROTOCOLS = radius
+
+$(foreach X,${PROTOCOLS},$(eval $(call FUZZ_PROTOCOL,${X})))
 endif
index a2fe4481eee7448f2f03b0e505c42ac43fb61b19..f5d7fdd3cd54bd49dbb82cbcd63e06c035569887 100644 (file)
@@ -9,12 +9,22 @@
 #
 #  FR_LIBRARY_PATH=./build/lib/ FR_LIBRARY_FUZZ_PROTOCOL=radius FR_DICTIONARY_DIR=./share/dictionary/ ./build/make/jlibtool --mode=execute ./build/bin/local/fuzzer /path/to/corpus/directory/
 #
-#  Command-line option parsing will be added later.
+
+#
+#  The libraries to be fuzzed MUST be explicitly linked to the protocol libraries.
+#  Dynamic loading will NOT work.  In order to simplify the process, the protocol
+#  libraries export a common test point.  We have one source / make file, which
+#  then magically turns into different fuzzers.
 #
-TARGET         := fuzzer
+#  However, because the *test point* functions are loaded dynamically,
+#  you still have to tell the fuzzer which library it's supposed to
+#  load.
+#
+
+TARGET         := fuzzer_$(PROTOCOL)
 SOURCES                := fuzzer.c
 
-TGT_PREREQS    := libfreeradius-util.a libfreeradius-radius.a
+TGT_PREREQS    := libfreeradius-util.a libfreeradius-$(PROTOCOL).a
 
 SRC_CFLAGS     := -fsanitize=fuzzer
 TGT_LDFLAGS    := -fsanitize=fuzzer