aboutsummaryrefslogtreecommitdiff
path: root/fuzz/Makefile
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2020-05-14 21:09:48 +0200
committerMarc André Tanner <mat@brain-dump.org>2020-05-14 21:38:43 +0200
commit38cc374f2acc3783c07db54012201a76b5d8fec3 (patch)
tree867388844ef10d6c90d5228d70bfee0f2f816742 /fuzz/Makefile
parent9d0c64515d924e9f5fcd31b72efb66469d5437dc (diff)
downloadvis-38cc374f2acc3783c07db54012201a76b5d8fec3.tar.gz
vis-38cc374f2acc3783c07db54012201a76b5d8fec3.tar.xz
test/fuzz: add libfuzzer target for text data structure
This reuses the existing fuzzing driver initially written for afl-fuzz. As a consequence, quite a bit of stdio code is involved which is probably not optimal.
Diffstat (limited to 'fuzz/Makefile')
-rw-r--r--fuzz/Makefile14
1 files changed, 11 insertions, 3 deletions
diff --git a/fuzz/Makefile b/fuzz/Makefile
index 26bb10c..6f5dc90 100644
--- a/fuzz/Makefile
+++ b/fuzz/Makefile
@@ -1,6 +1,6 @@
-include ../../config.mk
-ALL = text-fuzzer buffer-fuzzer
+ALL = text-fuzzer text-libfuzzer buffer-fuzzer
CC = afl-gcc
CFLAGS += -I. -I../.. -DBUFFER_SIZE=4 -DBLOCK_SIZE=4
@@ -8,7 +8,11 @@ test: $(ALL)
text-fuzzer: text-fuzzer.c fuzzer.h ../../text.c ../../text-util.c ../../text-motions.c ../../text-objects.c ../../text-regex.c
@echo Compiling $@ binary
- ${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_LIBC} ${CFLAGS_EXTRA} ${filter %.c, $^} ${LDFLAGS} -o $@
+ @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_LIBC} ${CFLAGS_EXTRA} ${filter %.c, $^} ${LDFLAGS} -o $@
+
+text-libfuzzer: text-fuzzer.c fuzzer.h ../../text.c ../../text-util.c ../../text-motions.c ../../text-objects.c ../../text-regex.c
+ @echo Compiling $@ binary
+ @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_LIBC} ${CFLAGS_EXTRA} -DLIBFUZZER ${filter %.c, $^} -fsanitize=fuzzer,address,undefined ${LDFLAGS} -o $@
buffer-fuzzer: buffer-fuzzer.c fuzzer.h ../../buffer.c
@echo Compiling $@ binary
@@ -22,6 +26,10 @@ afl-fuzz-text: text-fuzzer
@afl-fuzz -i - -x "dictionaries/$<.dict" -o "results/$<" -- "./$<" || \
afl-fuzz -i "inputs/$<" -x "dictionaries/$<.dict" -o "results/$<" -- "./$<"
+libfuzzer-text: text-libfuzzer
+ @mkdir -p "results/$<"
+ @./$< -close_fd_mask=1 -only_ascii=1 -print_final_stats=1 "-dict=dictionaries/$<.dict" "inputs/$<" "results/$<"
+
afl-fuzz-buffer: buffer-fuzzer
@mkdir -p "results/$<"
@afl-fuzz -i - -x "dictionaries/$<.dict" -o "results/$<" -- "./$<" || \
@@ -34,4 +42,4 @@ clean:
distclean: clean
@rm -rf results/
-.PHONY: clean distclean debug afl-fuzz-text afl-fuzz-buffer
+.PHONY: clean distclean debug afl-fuzz-text libfuzzer-text afl-fuzz-buffer