These will be useful for seeding AFL and may be useful for other
purposes. This also lets us check that at least with our existing
test cases, the corresponding fuzzer input files work.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
This reverts commit
44843c19f7b3ebf59aa4cda4cef9be0f5d973126.
regress/*_playback
regress/*_fuzz
regress/output-*.*
+regress/fuzz-*
regress/pipe.out
regress/pipe.err
regress/harness.h
@echo
@echo 'all tests passed or maybe skipped.'
+checkfuzz: $(TARGETS) $(addprefix checkfuzz-,$(ALL_TESTS))
+ @echo
+ @echo 'all fuzzes passed or maybe skipped.'
+# this target is mostly useful as prep work for running the fuzzer;
+# it doesn't really test any of adns
+
check-%: case-%.sys
@srcdir=$(srcdir) $(srcdir)/r1test $* || test $$? = 5
+fuzz-%: case-%.sys $(TARGETS) make1fuzz shlib
+ srcdir=$(srcdir) $(srcdir)/make1fuzz $*
+
+.PRECIOUS: fuzz-%
+
+checkfuzz-%: fuzz-% $(TARGETS)
+ @srcdir=$(srcdir) $(srcdir)/check1fuzz $< || test $$? = 5
+
LINK_CMD= $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
%_record: %_c.o hrecord.o hnonfuzz.o $(HARNLOBJS)
--- /dev/null
+#!/bin/sh
+# usage: check1fuzz <fuzzer stimulus file>
+# fuzz check script, for checking that one fuzz input works
+
+set -e
+: ${srcdir=.}
+. "$srcdir"/shlib
+
+fuzzfile="$1"
+
+exec <"$fuzzfile"
+
+desc="${fuzzfile#fuzz-}"
+
+read nargs
+if [ "$nargs" = 0 ]; then printf "SKIPPED-$desc "; exit 5; fi
+
+read arg1len
+read program
+
+case "$program" in
+*/*) ;;
+*) program="./$program" ;;
+esac
+
+${program} <"$fuzzfile" >/dev/null
+
+printf "$desc "
--- /dev/null
+#!/bin/sh
+set -e
+
+: ${srcdir=.}
+. "$srcdir"/shlib
+
+casename="$1"
+
+playback_prepare
+
+ofuzz="fuzz-$casename"
+
+rm -f "$ofuzz.tmp"
+exec >"$ofuzz.tmp"
+
+fuzzout_complete () {
+ mv "$ofuzz.tmp" "$ofuzz"
+ exit 0
+}
+
+if test ! -e $playback; then
+ echo 0
+ fuzzout_complete
+fi
+
+playback_execute_callback () {
+ set "${program}_fuzz" "$@"
+
+ printf "%d\n" "$#"
+ for a in "$@"; do
+ printf "%d\n" "${#a}"
+ printf "%s\n" "$a"
+ done
+}
+playback_execute
+
+if test -e "$case.in"
+then
+ inputsz=$(stat -c'%s' -L "$case.in")
+ printf "%d\n" "$inputsz"
+ cat "$case.in"
+else
+ echo 0
+fi
+echo
+
+cat <&4
+
+fuzzout_complete
rm -f $(TARGETS) $(AUTOCSRCS) $(AUTOCHDRS)
rm -f *.o *.tmp* *.so *.so.* pipe.*
rm -f output-*.err output-*.leftover
- rm -f output-*.out output-*.report
+ rm -f output-*.out output-*.report fuzz-*
distclean: clean
rm -f *~ ./#*# core *.orig *.rej Makefile config.h