Skip to content
Snippets Groups Projects
Commit 014540a0 authored by Ondřej Surý's avatar Ondřej Surý Committed by Daniel Salzman
Browse files

Add simple zscanner fuzzer

parent fe1454bb
No related branches found
No related tags found
1 merge request!834Update the libFuzzer support and run fuzzed inputs on normal make check in Gitlab CI
Pipeline #
[submodule "tests-fuzz/packet_libfuzzer.in"]
path = tests-fuzz/packet_libfuzzer.in
url = ../fuzzing/packet_libfuzzer.in.git
[submodule "tests-fuzz/zscanner_libfuzzer.in"]
path = tests-fuzz/zscanner_libfuzzer.in
url = ../fuzzing/zscanner_libfuzzer.in.git
......@@ -491,6 +491,7 @@ tests-fuzz/wrap/afl-loop.h
tests-fuzz/wrap/server.c
tests-fuzz/wrap/tcp-handler.c
tests-fuzz/wrap/udp-handler.c
tests-fuzz/zscanner_libfuzzer.c
tests/contrib/test_base32hex.c
tests/contrib/test_base64.c
tests/contrib/test_dynarray.c
......
......@@ -7,3 +7,4 @@
/*.trs
/*.log
/packet_libfuzzer
/zscanner_libfuzzer
......@@ -8,17 +8,23 @@ AM_CPPFLAGS = \
-DSRCDIR=\"$(abs_srcdir)\"
FUZZERS = \
packet_libfuzzer
packet_libfuzzer \
zscanner_libfuzzer
check_PROGRAMS = $(FUZZERS)
packet_libfuzzer_SOURCES = packet_libfuzzer.c
packet_libfuzzer_LDADD = $(top_builddir)/src/libknot.la
zscanner_libfuzzer_SOURCES = zscanner_libfuzzer.c
zscanner_libfuzzer_LDADD = $(top_builddir)/src/zscanner/libzscanner.la
if SANITIZE_FUZZER
packet_libfuzzer_LDFLAGS = -fsanitize=fuzzer
zscanner_libfuzzer_LDFLAGS = -fsanitize=fuzzer
else
packet_libfuzzer_SOURCES += main.c
zscanner_libfuzzer_SOURCES += main.c
AM_CPPFLAGS += -DTEST_RUN
TESTS = $(FUZZERS)
endif
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdint.h>
#include "zscanner/scanner.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
zs_scanner_t s = { 0 };
assert(zs_init(&s, ".", 1, 0) == 0);
assert(zs_set_input_string(&s, (const char *)data, size) == 0);
zs_parse_all(&s);
zs_deinit(&s);
return 0;
}
Subproject commit 91e31ee437c5ca34cfe836187136cefa54f887db
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment