diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:24:08 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:24:08 +0000 |
commit | f449f278dd3c70e479a035f50a9bb817a9b433ba (patch) | |
tree | 8ca2bfb785dda9bb4d573acdf9b42aea9cd51383 /tests-fuzz/Makefile.am | |
parent | Initial commit. (diff) | |
download | knot-f449f278dd3c70e479a035f50a9bb817a9b433ba.tar.xz knot-f449f278dd3c70e479a035f50a9bb817a9b433ba.zip |
Adding upstream version 3.2.6.upstream/3.2.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests-fuzz/Makefile.am')
-rw-r--r-- | tests-fuzz/Makefile.am | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/tests-fuzz/Makefile.am b/tests-fuzz/Makefile.am new file mode 100644 index 0000000..dcf18a6 --- /dev/null +++ b/tests-fuzz/Makefile.am @@ -0,0 +1,130 @@ +AM_CPPFLAGS = \ + -include $(top_builddir)/src/config.h \ + -I$(top_srcdir)/src \ + -DCONFIG_DIR='"${config_dir}"' \ + -DSTORAGE_DIR='"${storage_dir}"' \ + -DRUN_DIR='"${run_dir}"' \ + -DSRCDIR=\"$(abs_srcdir)\" + +FUZZERS = \ + fuzz_packet \ + fuzz_zscanner \ + fuzz_dname_to_str \ + fuzz_dname_from_str + +check_PROGRAMS = $(FUZZERS) + +if HAVE_DAEMON +# knotd_stdio (AFL) +check_PROGRAMS += knotd_stdio + +nodist_knotd_stdio_SOURCES = knotd_wrap/main.c + +knotd_stdio_SOURCES = \ + knotd_wrap/afl-loop.h \ + knotd_wrap/server.c \ + knotd_wrap/tcp-handler.c \ + knotd_wrap/udp-handler.c + +knotd_stdio_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(libkqueue_CFLAGS) \ + $(liburcu_CFLAGS) \ + $(lmdb_CFLAGS) \ + $(systemd_CFLAGS) + +knotd_stdio_LDADD = \ + $(top_builddir)/src/libknotd.la \ + $(top_builddir)/src/libknot.la \ + $(top_builddir)/src/libdnssec.la \ + $(top_builddir)/src/libcontrib.la \ + $(top_builddir)/src/libzscanner.la \ + $(cap_ng_LIBS) \ + $(gnutls_LIBS) \ + $(liburcu_LIBS) \ + $(lmdb_LIBS) \ + $(systemd_LIBS) + +BUILT_SOURCES = knotd_wrap/main.c +CLEANFILES = knotd_wrap/main.c +knotd_wrap/main.c: $(top_builddir)/src/utils/knotd/main.c + @echo '#include "knotd_wrap/afl-loop.h"' > $@ + @$(SED) -e 's/for (;;)/while (__AFL_LOOP(10000))/' $(top_srcdir)/src/utils/knotd/main.c >> $@ +endif HAVE_DAEMON + +# Simple function wrappers (AFL, libFuzzer, tests) + +fuzz_packet_SOURCES = fuzz_packet.c +fuzz_packet_CPPFLAGS = $(AM_CPPFLAGS) +fuzz_packet_LDADD = \ + $(top_builddir)/src/libknot.la \ + $(top_builddir)/src/libdnssec.la \ + $(top_builddir)/src/libcontrib.la \ + $(lmdb_LIBS) + +fuzz_zscanner_SOURCES = fuzz_zscanner.c +fuzz_zscanner_CPPFLAGS = $(AM_CPPFLAGS) +fuzz_zscanner_LDADD = \ + $(top_builddir)/src/libzscanner.la + +fuzz_dname_to_str_SOURCES = fuzz_dname_to_str.c +fuzz_dname_to_str_CPPFLAGS = $(AM_CPPFLAGS) +fuzz_dname_to_str_LDADD = \ + $(top_builddir)/src/libknot.la \ + $(top_builddir)/src/libdnssec.la \ + $(top_builddir)/src/libcontrib.la \ + $(lmdb_LIBS) + +fuzz_dname_from_str_SOURCES = fuzz_dname_from_str.c +fuzz_dname_from_str_CPPFLAGS = $(AM_CPPFLAGS) +fuzz_dname_from_str_LDADD = \ + $(top_builddir)/src/libknot.la \ + $(top_builddir)/src/libdnssec.la \ + $(top_builddir)/src/libcontrib.la \ + $(lmdb_LIBS) + +if OSS_FUZZ + +# CFLAGS, LDFLAGS, etc. are defined by the oss-fuzz environment; just link +# in the fuzzing engine + +fuzz_packet_LDADD += ${LIB_FUZZING_ENGINE} -lc++ +fuzz_zscanner_LDADD += ${LIB_FUZZING_ENGINE} -lc++ +fuzz_dname_to_str_LDADD += ${LIB_FUZZING_ENGINE} -lc++ +fuzz_dname_from_str_LDADD += ${LIB_FUZZING_ENGINE} -lc++ + +else + +if FUZZER + +fuzz_packet_CPPFLAGS += ${fuzzer_CFLAGS} +fuzz_packet_LDFLAGS = ${fuzzer_LDFLAGS} + +fuzz_zscanner_CPPFLAGS += ${fuzzer_CFLAGS} +fuzz_zscanner_LDFLAGS = ${fuzzer_LDFLAGS} + +fuzz_dname_to_str_CPPFLAGS += ${fuzzer_CFLAGS} +fuzz_dname_to_str_LDFLAGS = ${fuzzer_LDFLAGS} + +fuzz_dname_from_str_CPPFLAGS += ${fuzzer_CFLAGS} +fuzz_dname_from_str_LDFLAGS = ${fuzzer_LDFLAGS} + +# Ensure that fuzzers execute successfully with a benign input + +TESTS = check/check_fuzzers.test +EXTRA_DIST = check/check_fuzzers.test + +else + +fuzz_packet_SOURCES += main.c +fuzz_zscanner_SOURCES += main.c +fuzz_dname_to_str_SOURCES += main.c +fuzz_dname_from_str_SOURCES += main.c + +TESTS = $(FUZZERS) + +endif # if FUZZER + +endif # if OSS_FUZZ + +check-compile: $(check_PROGRAMS) |