Commit 1c57b73e authored by Bhargava Shastry's avatar Bhargava Shastry Committed by Ondřej Surý

oss-fuzz: Improve interaction with fuzzing tools and add new tests in fuzz/ directory

parent d30b90db
Pipeline #3959 passed with stages
in 8 minutes and 22 seconds
......@@ -14,7 +14,7 @@ top_builddir = @top_builddir@
VERSION=@BIND9_VERSION@
SUBDIRS = make unit lib bin doc
SUBDIRS = make unit lib fuzz bin doc
TARGETS =
PREREQS = bind.keys.h
......@@ -90,6 +90,7 @@ force-test: test-force
test-force:
status=0; \
(cd fuzz && ${MAKE} check) || status=1; \
(cd bin/tests && ${MAKE} ${MAKEDEFS} test) || status=1; \
(test -f ${top_builddir}/unit/unittest.sh && \
$(SHELL) ${top_builddir}/unit/unittest.sh) || status=1; \
......
......@@ -1008,7 +1008,7 @@ plus_option(char *option, bool is_batchfile,
code = NULL;
if (value != NULL) {
code = strtok_r(value,
":",
":",
&last);
}
if (code == NULL) {
......
......@@ -36,10 +36,6 @@
#include <unistd.h>
#include <pthread.h>
#ifndef __AFL_LOOP
#error To use American Fuzzy Lop you have to set CC to afl-clang-fast!!!
#endif
/*
* We are using pthreads directly because we might be using it with
* unthreaded version of BIND, where all thread functions are
......@@ -61,7 +57,6 @@ fuzz_thread_client(void *arg) {
char *port;
struct sockaddr_in servaddr;
int sockfd;
int loop;
void *buf;
UNUSED(arg);
......@@ -103,14 +98,18 @@ fuzz_thread_client(void *arg) {
* Processing fuzzed packets 100,000 times before shutting down
* the app.
*/
for (loop = 0; loop < 100000; loop++) {
#ifdef __AFL_LOOP
for (int loop = 0; loop < 100000; loop++) {
#else
{
#endif
ssize_t length;
ssize_t sent;
length = read(0, buf, 65536);
if (length <= 0) {
usleep(1000000);
continue;
goto next;
}
/*
......@@ -130,7 +129,7 @@ fuzz_thread_client(void *arg) {
return (NULL);
}
raise(SIGSTOP);
continue;
goto next;
}
RUNTIME_CHECK(pthread_mutex_lock(&mutex) == 0);
......@@ -151,6 +150,7 @@ fuzz_thread_client(void *arg) {
pthread_cond_wait(&cond, &mutex);
RUNTIME_CHECK(pthread_mutex_unlock(&mutex) == 0);
next: ;
}
free(buf);
......@@ -586,6 +586,7 @@ fuzz_thread_resolver(void *arg) {
named_server_flushonshutdown(named_g_server, false);
isc_app_shutdown();
#ifdef __AFL_LOOP
/*
* This is here just for the signature, that's how AFL detects
* if it's a 'persistent mode' binary. It has to occur somewhere
......@@ -594,6 +595,7 @@ fuzz_thread_resolver(void *arg) {
* in persistent mode if it's present.
*/
__AFL_LOOP(0);
#endif
return (NULL);
}
......
......@@ -952,7 +952,7 @@ enable_buffer_useinline
enable_warn_shadow
enable_warn_error
enable_developer
enable_afl
enable_fuzzing
with_python
with_python_install_dir
enable_kqueue
......@@ -1657,7 +1657,9 @@ Optional Features:
--enable-warn-shadow turn on -Wshadow when compiling
--enable-warn-error turn on -Werror when compiling
--enable-developer enable developer build settings
--enable-afl enable American Fuzzy Lop test harness [default=no]
--enable-fuzzing=<afl|libfuzzer>
Enable fuzzing using American Fuzzy Lop or libFuzzer
(default=no)
--enable-kqueue use BSD kqueue when available [default=yes]
--enable-epoll use Linux epoll when available [default=auto]
--enable-devpoll use /dev/poll when available [default=yes]
......@@ -12082,14 +12084,67 @@ yes)
esac
# American Fuzzy Lop
# Check whether --enable-afl was given.
if test "${enable_afl+set}" = set; then :
enableval=$enable_afl;
# Check whether --enable-fuzzing was given.
if test "${enable_fuzzing+set}" = set; then :
enableval=$enable_fuzzing;
else
enable_fuzzing=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable fuzzing mode" >&5
$as_echo_n "checking whether to enable fuzzing mode... " >&6; }
case $enable_fuzzing in #(
no) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; } ;; #(
afl) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using AFL" >&5
$as_echo "using AFL" >&6; }
$as_echo "#define ENABLE_AFL 1" >>confdefs.h
CFLAGS="$CFLAGS -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1"
LIBS="$LIBS -lpthread" ;; #(
libfuzzer) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using libFuzzer" >&5
$as_echo "using libFuzzer" >&6; }
CFLAGS="$CFLAGS -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1 -fsanitize=fuzzer,address,undefined"
LDFLAGS="$LDFLAGS -fsanitize=fuzzer,address,undefined" ;; #(
*) :
as_fn_error $? "You need to explicitly select the fuzzer" "$LINENO" 5 ;; #(
*) :
;;
esac
if test "$enable_fuzzing" = "afl"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking \"for AFL enabled compiler\"" >&5
$as_echo_n "checking \"for AFL enabled compiler\"... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
#ifndef __AFL_COMPILER
#error AFL compiler required
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
as_fn_error $? "set CC=afl-<gcc|clang> when --enable-fuzzing=afl is used" "$LINENO" 5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
#
# Make very sure that these are the first files processed by
......@@ -23663,7 +23718,7 @@ ac_config_commands="$ac_config_commands chmod"
# elsewhere if there's a good reason for doing so.
#
ac_config_files="$ac_config_files make/Makefile make/mkdep Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/delv/Makefile bin/dig/Makefile bin/dnssec/Makefile bin/named/Makefile bin/named/unix/Makefile bin/nsupdate/Makefile bin/pkcs11/Makefile bin/python/Makefile bin/python/isc/Makefile bin/python/isc/utils.py bin/python/isc/tests/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/python/dnssec-keymgr.py bin/python/isc/__init__.py bin/python/isc/checkds.py bin/python/isc/coverage.py bin/python/isc/dnskey.py bin/python/isc/eventlist.py bin/python/isc/keydict.py bin/python/isc/keyevent.py bin/python/isc/keymgr.py bin/python/isc/keyseries.py bin/python/isc/keyzone.py bin/python/isc/policy.py bin/python/isc/rndc.py bin/python/isc/tests/dnskey_test.py bin/python/isc/tests/policy_test.py bin/rndc/Makefile bin/tests/Makefile bin/tests/headerdep_test.sh bin/tests/optional/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/dlz/prereq.sh bin/tests/system/dlzexternal/Makefile bin/tests/system/dlzexternal/ns1/dlzs.conf bin/tests/system/dyndb/Makefile bin/tests/system/dyndb/driver/Makefile bin/tests/system/inline/checkdsa.sh bin/tests/system/pipelined/Makefile bin/tests/system/rndc/Makefile bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/tkey/Makefile bin/tests/virtual-time/Makefile bin/tests/virtual-time/conf.sh bin/tools/Makefile contrib/scripts/check-secure-delegation.pl contrib/scripts/zone-edit.sh doc/Makefile doc/arm/Makefile doc/arm/noteversion.xml doc/arm/pkgversion.xml doc/arm/releaseinfo.xml doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/misc/Makefile doc/tex/Makefile doc/tex/armstyle.sty doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-manpage.xsl doc/xsl/isc-notes-html.xsl isc-config.sh lib/Makefile lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/dns/tests/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/irs/tests/Makefile lib/isc/$arch/Makefile lib/isc/$arch/include/Makefile lib/isc/$arch/include/isc/Makefile lib/isc/pthreads/Makefile lib/isc/pthreads/include/Makefile lib/isc/pthreads/include/isc/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/include/pk11/Makefile lib/isc/include/pkcs11/Makefile lib/isc/tests/Makefile lib/isc/nls/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isc/unix/include/pkcs11/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/isccfg/tests/Makefile lib/ns/Makefile lib/ns/include/Makefile lib/ns/include/ns/Makefile lib/ns/tests/Makefile lib/samples/Makefile lib/samples/Makefile-postinstall unit/Makefile unit/unittest.sh"
ac_config_files="$ac_config_files make/Makefile make/mkdep Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/delv/Makefile bin/dig/Makefile bin/dnssec/Makefile bin/named/Makefile bin/named/unix/Makefile bin/nsupdate/Makefile bin/pkcs11/Makefile bin/python/Makefile bin/python/isc/Makefile bin/python/isc/utils.py bin/python/isc/tests/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/python/dnssec-keymgr.py bin/python/isc/__init__.py bin/python/isc/checkds.py bin/python/isc/coverage.py bin/python/isc/dnskey.py bin/python/isc/eventlist.py bin/python/isc/keydict.py bin/python/isc/keyevent.py bin/python/isc/keymgr.py bin/python/isc/keyseries.py bin/python/isc/keyzone.py bin/python/isc/policy.py bin/python/isc/rndc.py bin/python/isc/tests/dnskey_test.py bin/python/isc/tests/policy_test.py bin/rndc/Makefile bin/tests/Makefile bin/tests/headerdep_test.sh bin/tests/optional/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/dlz/prereq.sh bin/tests/system/dlzexternal/Makefile bin/tests/system/dlzexternal/ns1/dlzs.conf bin/tests/system/dyndb/Makefile bin/tests/system/dyndb/driver/Makefile bin/tests/system/inline/checkdsa.sh bin/tests/system/pipelined/Makefile bin/tests/system/rndc/Makefile bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/tkey/Makefile bin/tests/virtual-time/Makefile bin/tests/virtual-time/conf.sh bin/tools/Makefile contrib/scripts/check-secure-delegation.pl contrib/scripts/zone-edit.sh doc/Makefile doc/arm/Makefile doc/arm/noteversion.xml doc/arm/pkgversion.xml doc/arm/releaseinfo.xml doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/misc/Makefile doc/tex/Makefile doc/tex/armstyle.sty doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-manpage.xsl doc/xsl/isc-notes-html.xsl isc-config.sh lib/Makefile lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/dns/tests/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/irs/tests/Makefile lib/isc/$arch/Makefile lib/isc/$arch/include/Makefile lib/isc/$arch/include/isc/Makefile lib/isc/pthreads/Makefile lib/isc/pthreads/include/Makefile lib/isc/pthreads/include/isc/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/include/pk11/Makefile lib/isc/include/pkcs11/Makefile lib/isc/tests/Makefile lib/isc/nls/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isc/unix/include/pkcs11/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/isccfg/tests/Makefile lib/ns/Makefile lib/ns/include/Makefile lib/ns/include/ns/Makefile lib/ns/tests/Makefile lib/samples/Makefile lib/samples/Makefile-postinstall unit/Makefile unit/unittest.sh fuzz/Makefile"
#
......@@ -24789,6 +24844,7 @@ do
"lib/samples/Makefile-postinstall") CONFIG_FILES="$CONFIG_FILES lib/samples/Makefile-postinstall" ;;
"unit/Makefile") CONFIG_FILES="$CONFIG_FILES unit/Makefile" ;;
"unit/unittest.sh") CONFIG_FILES="$CONFIG_FILES unit/unittest.sh" ;;
"fuzz/Makefile") CONFIG_FILES="$CONFIG_FILES fuzz/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
......
......@@ -98,13 +98,37 @@ yes)
esac
AC_SUBST(XTARGETS)
# American Fuzzy Lop
AC_ARG_ENABLE(afl,
AS_HELP_STRING([--enable-afl],
[enable American Fuzzy Lop test harness
[default=no]]),
[AC_DEFINE([ENABLE_AFL], [1],
[Define to enable American Fuzzy Lop test harness])])
AC_ARG_ENABLE([fuzzing],
[AS_HELP_STRING([--enable-fuzzing=<afl|libfuzzer>],
[Enable fuzzing using American Fuzzy Lop or libFuzzer (default=no)])],
[],
[enable_fuzzing=no])
AC_MSG_CHECKING([whether to enable fuzzing mode])
AS_CASE([$enable_fuzzing],
[no],[AC_MSG_RESULT([no])],
[afl],[
AC_MSG_RESULT([using AFL])
AC_DEFINE([ENABLE_AFL], [1],
[Define to enable American Fuzzy Lop test harness])
CFLAGS="$CFLAGS -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1"
LIBS="$LIBS -lpthread"],
[libfuzzer],[
AC_MSG_RESULT([using libFuzzer])
CFLAGS="$CFLAGS -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1 -fsanitize=fuzzer,address,undefined"
LDFLAGS="$LDFLAGS -fsanitize=fuzzer,address,undefined"],
[*],[AC_MSG_ERROR([You need to explicitly select the fuzzer])])
AS_IF([test "$enable_fuzzing" = "afl"],
[AC_MSG_CHECKING("for AFL enabled compiler")
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[#ifndef __AFL_COMPILER
#error AFL compiler required
#endif
])],
[AC_MSG_RESULT([yes])],
[AC_MSG_ERROR([set CC=afl-<gcc|clang> when --enable-fuzzing=afl is used])])
])
#
# Make very sure that these are the first files processed by
......@@ -4332,6 +4356,7 @@ AC_CONFIG_FILES([
lib/samples/Makefile-postinstall
unit/Makefile
unit/unittest.sh
fuzz/Makefile
])
#
......
/*.dSYM/
dns_name_fromtext_target
/*.out/
= Fuzzing
The tests in this directory can be operated in three modes:
* non-fuzzing - the test just runs over all input located in `<test_name>.in/`
directory by compiling with mock main.c that walks through the directory and
runs `LLVMFuzzerTestOneInput()` over the input files
* AFL - `./configure --with-fuzzing=afl` will either feed the stdin to
`LLVMFuzzerTestOneInput()` or run the `__AFL_LOOP(10000)` if compiled with
`afl-clang-fast`
* LibFuzzer - `./configure --with-fuzzing=libfuzzer` will disable `main.c`
completely and it uses the standard LibFuzzer mechanims to feed
`LLVMFuzzerTestOneInput` with the fuzzer
== Test Cases
Each test case should be called descriptively and the executable target must
link `testcase.o` and `main.o` and the `test_case.c` must have a function
`LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)`.
== Adding more fuzzers
To add a different fuzzer, `main.c` must be modified to include `main()` function
for a specific fuzzer (or no function as is case with LibFuzzer).
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
abs_srcdir = @abs_srcdir@
@BIND9_MAKE_INCLUDES@
CINCLUDES = -I. -I.. ${DNS_INCLUDES} ${ISC_INCLUDES} \
@OPENSSL_INCLUDES@
CDEFINES = -DFUZZDIR=\"$(abs_srcdir)\"
ISCLIBS = ../lib/isc/libisc.@A@ @OPENSSL_LIBS@
ISCDEPLIBS = ../lib/isc/libisc.@A@
DNSLIBS = ../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@
DNSDEPLIBS = ../lib/dns/libdns.@A@
LIBS = @LIBS@
OBJS = main.@O@
SRCS = main.c dns_name_fromtext_target.c
SUBDIRS =
TARGETS = dns_name_fromtext_target@EXEEXT@
@BIND9_MAKE_RULES@
dns_name_fromtext_target@EXEEXT@: dns_name_fromtext_target.@O@ main.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
dns_name_fromtext_target.@O@ main.@O@ ${DNSLIBS} ${ISCLIBS} ${LIBS}
check: ${TARGETS}
for fuzzer in ${TARGETS}; do \
./$${fuzzer} \
done
oss-fuzz: ${TARGETS}
clean distclean::
rm -f ${TARGETS}
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#include <stddef.h>
#include <stdint.h>
#include <isc/buffer.h>
#include <isc/util.h>
#include <dns/fixedname.h>
#include <dns/name.h>
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
isc_buffer_t buf;
isc_result_t result;
dns_fixedname_t origin;
char *de_const;
if (size < 5) {
return 0;
}
dns_fixedname_init(&origin);
DE_CONST(data, de_const);
isc_buffer_init(&buf, (void *)de_const, size);
isc_buffer_add(&buf, size);
result = dns_name_fromtext(dns_fixedname_name(&origin), &buf, dns_rootname, 0, NULL);
UNUSED(result);
return 0;
}
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#include <config.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <isc/lang.h>
#include <isc/mem.h>
#include <isc/once.h>
#include <isc/types.h>
#include <isc/util.h>
#include <dst/dst.h>
ISC_LANG_BEGINDECLS
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
static isc_mem_t *mctx = NULL;
static void __attribute__((constructor)) init(void) {
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(dst_lib_init(mctx, NULL) == ISC_R_SUCCESS);
}
static void __attribute__((destructor)) deinit(void)
{
dst_lib_destroy();
isc_mem_destroy(&mctx);
}
ISC_LANG_ENDDECLS
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#include <config.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>
#include "fuzz.h"
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
#include <dirent.h>
static void test_all_from(const char *dirname)
{
DIR *dirp;
struct dirent *dp;
dirp = opendir(dirname);
if (dirp == NULL) {
return;
}
while ((dp = readdir(dirp)) != NULL) {
char filename[strlen(dirname) + strlen(dp->d_name) + 2];
int fd;
struct stat st;
char *data;
ssize_t n;
if (dp->d_name[0] == '.') {
continue;
}
snprintf(filename, sizeof(filename), "%s/%s",
dirname, dp->d_name);
if ((fd = open(filename, O_RDONLY)) == -1) {
fprintf(stderr, "Failed to open %s: %s\n", filename,
strerror(errno));
continue;
}
if (fstat(fd, &st) != 0) {
fprintf(stderr, "Failed to stat %s: %s\n", filename,
strerror(errno));
goto closefd;
}
data = malloc(st.st_size);
n = read(fd, data, st.st_size);
if (n == st.st_size) {
printf("testing %zd bytes from %s\n",
n, filename);
fflush(stdout);
LLVMFuzzerTestOneInput((const uint8_t *)data, n);
fflush(stderr);
} else {
if (n < 0) {
fprintf(stderr,
"Failed to read %zd bytes from %s: %s\n",
(ssize_t) st.st_size, filename,
strerror(errno));
} else {
fprintf(stderr,
"Failed to read %zd bytes from %s"
", got %zd\n",
(ssize_t) st.st_size, filename,
n);
}
}
free(data);
closefd:
close(fd);
}
closedir(dirp);
}
int main(int argc, char **argv)
{
char corpusdir[PATH_MAX];
const char *target = strrchr(argv[0], '/');
UNUSED(argc);
UNUSED(argv);
target = target ? target + 1 : argv[0];
if (strncmp(target, "lt-", 3) == 0) {
target += 3;
}
snprintf(corpusdir, sizeof(corpusdir), FUZZDIR "/%s.in", target);
test_all_from(corpusdir);
return 0;
}
#elif __AFL_COMPILER
int main(int argc, char **argv)
{
int ret;
unsigned char buf[64 * 1024];
UNUSED(argc);
UNUSED(argv);
#ifdef __AFL_LOOP
while (__AFL_LOOP(10000)) { // only works with afl-clang-fast
#else
{
#endif
ret = fread(buf, 1, sizeof(buf), stdin);
if (ret < 0) {
return 0;
}
LLVMFuzzerTestOneInput(buf, ret);
}
return 0;
}
#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
......@@ -66,7 +66,11 @@ static isc_once_t isc_random_once = ISC_ONCE_INIT;
static void
isc_random_initialize(void) {
#if FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
memset(seed, 0, sizeof(seed));
#else
isc_entropy_get(seed, sizeof(seed));
#endif
}
uint8_t
......
This diff is collapsed.
......@@ -35,8 +35,12 @@ while (<CHANGES>) {
/CVS/ | # CVS directory
/\.git/ | # git directory
/\.gitignore | # .gitignore files
/Makefile.in | # build system doesn't need to have copyright
/configure | # build system doesn't need to have copyright
/fuzz/.*\.in/ | # ignore fuzz corpus
util/newcopyrights | # our output
\.bak$ | # created by update_copyrights
\.md$ | # READMEs and such
/(dnssafe|openssl)/.*\.[ch]$ | # imported
doc/(draft|expired|rfc)/ # imported
%x);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment