Skip to content

Commit 1dcffc6

Browse files
fix(fuzz): Make sanitizer flags optional
Currently OSS fuzz expects to have complete control over the sanitizer flags. As we currently have these set it's causing problems with the OSS fuzz build. Instead we should use the provided variables from the OSS fuzz build environment. For local testing we'll create a set a well defined defaults.
1 parent 549bee9 commit 1dcffc6

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
3939
- name: Build Fuzzer
4040
run: |
41+
export CC=clang
42+
export CXX=clang++
4143
fuzz_harness=$(ls -d test/fuzz/device/*/)
4244
for h in $fuzz_harness
4345
do

test/fuzz/make.mk

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ __check_defined = \
1616

1717
#-------------- Fuzz harness compiler ------------
1818

19-
CC = clang
20-
CXX = clang++
21-
GDB = gdb
19+
CC ?= clang
20+
CXX ?= clang++
21+
GDB ?= gdb
2222
OBJCOPY = objcopy
2323
SIZE = size
2424
MKDIR = mkdir
@@ -34,6 +34,13 @@ else
3434
PYTHON = python3
3535
endif
3636

37+
#-------------- Fuzz harness flags ------------
38+
COVERAGE_FLAGS ?= -fsanitize-coverage=trace-pc-guard
39+
SANITIZER_FLAGS ?= -fsanitize=fuzzer \
40+
-fsanitize=address
41+
42+
CFLAGS += $(COVERAGE_FLAGS) $(SANITIZER_FLAGS)
43+
3744
#-------------- Source files and compiler flags --------------
3845

3946

@@ -42,9 +49,6 @@ INC += $(TOP)/test
4249
# Compiler Flags
4350
CFLAGS += \
4451
-ggdb \
45-
-fsanitize=fuzzer \
46-
-fsanitize=address \
47-
-fsanitize=undefined \
4852
-fdata-sections \
4953
-ffunction-sections \
5054
-fno-strict-aliasing \

0 commit comments

Comments
 (0)