From d438b4a3cebcceb443747346c8ad91666a1ef325 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 7 Jun 2019 23:57:02 +0300 Subject: [PATCH] tests: Fix CFLAGS passing for new fuzzing tools src/*/Makefile needs to allow additional CFLAGS values to be provided from the calling Makefiles so that the clang command line arguments to enable sanitizers consistently. In addition, it can be useful to be able to provide CC, CFLAGS, and LDFLAGS from external setup while still requesing LIBFUZZER=y build. Allow that by not overriding these variables if they are already set. Signed-off-by: Jouni Malinen --- src/lib.rules | 1 + tests/fuzzing/rules.include | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/lib.rules b/src/lib.rules index 4ec4711e3..a46315442 100644 --- a/src/lib.rules +++ b/src/lib.rules @@ -11,6 +11,7 @@ CFLAGS += -DCONFIG_NO_RANDOM_POOL CFLAGS += -DTEST_FUZZ endif +CFLAGS += $(FUZZ_CFLAGS) CFLAGS += -I.. -I../utils diff --git a/tests/fuzzing/rules.include b/tests/fuzzing/rules.include index 69548cd74..a3b0ee0aa 100644 --- a/tests/fuzzing/rules.include +++ b/tests/fuzzing/rules.include @@ -1,9 +1,21 @@ +FUZZ_CFLAGS = + +ifdef LIBFUZZER +CC ?= clang +#FUZZ_FLAGS ?= -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow +FUZZ_FLAGS ?= -fsanitize=fuzzer,address +ifndef CFLAGS +FUZZ_CFLAGS += $(FUZZ_FLAGS) +endif +endif + +FUZZ_CFLAGS += -DCONFIG_NO_RANDOM_POOL -DTEST_FUZZ +export FUZZ_CFLAGS +CFLAGS ?= -MMD -O2 -Wall -g +CFLAGS += $(FUZZ_CFLAGS) ifdef LIBFUZZER -CC=clang -CFLAGS = -MMD -O2 -Wall -g -CFLAGS += -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow CFLAGS += -DTEST_LIBFUZZER -LDFLAGS += -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow +LDFLAGS += $(FUZZ_FLAGS) endif ifndef CC @@ -14,13 +26,6 @@ ifndef LDO LDO=$(CC) endif -ifndef CFLAGS -CFLAGS = -MMD -O2 -Wall -g -endif - -CFLAGS += -DCONFIG_NO_RANDOM_POOL -CFLAGS += -DTEST_FUZZ - WPAS_SRC=../../../wpa_supplicant SRC=../../../src @@ -34,7 +39,7 @@ $(SRC)/common/libcommon.a: $(MAKE) -C $(SRC)/common $(SRC)/crypto/libcrypto.a: - $(MAKE) -C $(SRC)/crypto + $(MAKE) -C $(SRC)/crypto TEST_FUZZ=y $(SRC)/eapol_auth/libeapol_auth.a: $(MAKE) -C $(SRC)/eapol_auth