Add install-fuzz Makefile target to install the fuzzers and seed corpus.

The FUZZ_DESTDIR make variable needs to be set in the environment
or on the command line.
This commit is contained in:
Todd C. Miller
2021-02-18 19:38:54 -07:00
parent 5ea2acc4c2
commit 9f1e016cde
19 changed files with 167 additions and 10 deletions

View File

@@ -113,6 +113,7 @@ TEST_LDFLAGS = @LDFLAGS@
LIBFUZZSTUB = $(top_builddir)/lib/fuzzstub/libsudo_fuzzstub.la
LIB_FUZZING_ENGINE = @FUZZ_ENGINE@
FUZZ_PROGS = fuzz_sudo_conf
FUZZ_SEED_CORPUS = ${FUZZ_PROGS:=_seed_corpus.zip}
FUZZ_LIBS = @LIBS@ $(LIB_FUZZING_ENGINE)
FUZZ_LDFLAGS = @LDFLAGS@
@@ -175,6 +176,8 @@ VSYSLOG_TEST_OBJS = vsyslog_test.lo vsyslog.lo
FUZZ_SUDO_CONF_OBJS = fuzz_sudo_conf.lo
FUZZ_SUDO_CONF_CORPUS = $(srcdir)/regress/corpus/sudo_conf/sudo.conf.*
all: libsudo_util.la
pvs-log-files: $(POBJS)
@@ -291,6 +294,15 @@ vsyslog_test: $(VSYSLOG_TEST_OBJS) libsudo_util.la
fuzz_sudo_conf: $(FUZZ_SUDO_CONF_OBJS) $(LIBFUZZSTUB) libsudo_util.la
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(FUZZ_SUDO_CONF_OBJS) libsudo_util.la $(ASAN_LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(FUZZ_LDFLAGS) $(FUZZ_LIBS)
fuzz_sudo_conf_seed_corpus.zip:
tdir=fuzz_sudo_conf.$$$$; \
mkdir $$tdir; \
for f in $(FUZZ_SUDO_CONF_CORPUS); do \
cp $$f $$tdir/`sha1sum $$f | cut -d' ' -f1`; \
done; \
zip -j $@ $$tdir/*; \
rm -rf $$tdir
pre-install:
install: install-dirs
@@ -312,6 +324,13 @@ install-doc:
install-plugin:
install-fuzzer: $(FUZZ_PROGS) $(FUZZ_SEED_CORPUS)
@if test X"$(FUZZ_DESTDIR)" = X""; then \
echo "must set FUZZ_DESTDIR for install-fuzzer target"; \
else \
cp $(FUZZ_PROGS) $(FUZZ_SEED_CORPUS) $(FUZZ_DESTDIR); \
fi
uninstall:
$(LIBTOOL) $(LTFLAGS) --mode=uninstall rm -f $(DESTDIR)$(libexecdir)/sudo/libsudo_util.la
-test -z "$(INSTALL_BACKUP)" || \
@@ -330,7 +349,7 @@ fuzz: $(FUZZ_PROGS)
MALLOC_OPTIONS=S; export MALLOC_OPTIONS; \
MALLOC_CONF="abort:true,junk:true"; export MALLOC_CONF; \
echo "fuzz_sudo_conf: verifying corpus"; \
./fuzz_sudo_conf $(srcdir)/regress/corpus/sudo_conf/sudo.conf.*; \
./fuzz_sudo_conf $(FUZZ_SUDO_CONF_CORPUS); \
fi
# Note: some regress checks are run from srcdir for consistent error messages
@@ -446,6 +465,8 @@ realclean: distclean
cleandir: realclean
.PHONY: $(FUZZ_SEED_CORPUS)
# Autogenerated dependencies, do not modify
aix.lo: $(srcdir)/aix.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \