diff --git a/Makefile.in b/Makefile.in index eaabcd39d..ee430b370 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,7 @@ # # SPDX-License-Identifier: ISC # -# Copyright (c) 2010-2015, 2017-2020 Todd C. Miller +# Copyright (c) 2010-2015, 2017-2021 Todd C. Miller # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -110,7 +110,7 @@ all: config.status exit $$?; \ done -check check-fuzzer pre-install: config.status +check check-fuzzer fuzz pre-install: config.status for d in $(SUBDIRS); do \ (cd $$d && exec $(MAKE) $@) && continue; \ exit $$?; \ diff --git a/doc/Makefile.in b/doc/Makefile.in index 54dee9b70..a6efcca3d 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -406,6 +406,8 @@ pvs-log-files: pvs-studio: +fuzz: + check-fuzzer: check: check-fuzzer diff --git a/examples/Makefile.in b/examples/Makefile.in index 10d0740c5..823655d79 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -104,6 +104,8 @@ pvs-log-files: pvs-studio: +fuzz: + check-fuzzer: check: check-fuzzer diff --git a/include/Makefile.in b/include/Makefile.in index 3561c8fca..fcddad418 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -90,6 +90,8 @@ pvs-log-files: pvs-studio: +fuzz: + check-fuzzer: check: check-fuzzer diff --git a/lib/eventlog/Makefile.in b/lib/eventlog/Makefile.in index 25bdb73df..7f62355d4 100644 --- a/lib/eventlog/Makefile.in +++ b/lib/eventlog/Makefile.in @@ -146,6 +146,8 @@ cppcheck: pvs-log-files: $(POBJS) +fuzz: + check-fuzzer: check: $(TEST_PROGS) check-fuzzer diff --git a/lib/fuzzstub/Makefile.in b/lib/fuzzstub/Makefile.in index 07b095bfe..5f6ad0c2b 100644 --- a/lib/fuzzstub/Makefile.in +++ b/lib/fuzzstub/Makefile.in @@ -139,6 +139,8 @@ cppcheck: pvs-log-files: $(POBJS) +fuzz: + check-fuzzer: check: check-fuzzer diff --git a/lib/iolog/Makefile.in b/lib/iolog/Makefile.in index 4f19563fd..1b35f8cf8 100644 --- a/lib/iolog/Makefile.in +++ b/lib/iolog/Makefile.in @@ -87,6 +87,8 @@ FUZZ_PROGS = fuzz_iolog_json fuzz_iolog_legacy fuzz_iolog_timing FUZZ_SEED_CORPUS = ${FUZZ_PROGS:=_seed_corpus.zip} FUZZ_LIBS = @LIBS@ $(LIB_FUZZING_ENGINE) FUZZ_LDFLAGS = @LDFLAGS@ +FUZZ_MAX_LEN = 4096 +FUZZ_RUNS = 8192 # Set to non-empty for development mode DEVEL = @DEVEL@ @@ -191,6 +193,23 @@ fuzz_iolog_json_seed_corpus.zip: zip -j $@ $$tdir/*; \ rm -rf $$tdir +run-fuzz_iolog_json: fuzz_iolog_json + if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ + LC_ALL=C.UTF-8; export LC_ALL; \ + else \ + LC_ALL=C; export LC_ALL; \ + fi; \ + unset LANG || LANG=; \ + MALLOC_OPTIONS=S; export MALLOC_OPTIONS; \ + MALLOC_CONF="abort:true,junk:true"; export MALLOC_CONF; \ + umask 022; \ + corpus=regress/corpus/iolog_json; \ + mkdir -p $$corpus; \ + for f in $(FUZZ_IOLOG_JSON_CORPUS); do \ + cp $$f $$corpus; \ + done; \ + ./fuzz_iolog_json -dict=$(srcdir)/regress/fuzz/fuzz_iolog_json.dict -max_len=$(FUZZ_MAX_LEN) -runs=$(FUZZ_RUNS) $$corpus + fuzz_iolog_legacy_seed_corpus.zip: tdir=fuzz_iolog_legacy.$$$$; \ mkdir $$tdir; \ @@ -200,6 +219,23 @@ fuzz_iolog_legacy_seed_corpus.zip: zip -j $@ $$tdir/*; \ rm -rf $$tdir +run-fuzz_iolog_legacy: fuzz_iolog_legacy + if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ + LC_ALL=C.UTF-8; export LC_ALL; \ + else \ + LC_ALL=C; export LC_ALL; \ + fi; \ + unset LANG || LANG=; \ + MALLOC_OPTIONS=S; export MALLOC_OPTIONS; \ + MALLOC_CONF="abort:true,junk:true"; export MALLOC_CONF; \ + umask 022; \ + corpus=regress/corpus/iolog_legacy; \ + mkdir -p $$corpus; \ + for f in $(FUZZ_IOLOG_LEGACY_CORPUS); do \ + cp $$f $$corpus; \ + done; \ + ./fuzz_iolog_legacy -max_len=$(FUZZ_MAX_LEN) -runs=$(FUZZ_RUNS) $$corpus + fuzz_iolog_timing_seed_corpus.zip: tdir=fuzz_iolog_timing.$$$$; \ mkdir $$tdir; \ @@ -209,6 +245,23 @@ fuzz_iolog_timing_seed_corpus.zip: zip -j $@ $$tdir/*; \ rm -rf $$tdir +run-fuzz_iolog_timing: fuzz_iolog_timing + if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ + LC_ALL=C.UTF-8; export LC_ALL; \ + else \ + LC_ALL=C; export LC_ALL; \ + fi; \ + unset LANG || LANG=; \ + MALLOC_OPTIONS=S; export MALLOC_OPTIONS; \ + MALLOC_CONF="abort:true,junk:true"; export MALLOC_CONF; \ + umask 022; \ + corpus=regress/corpus/iolog_timing; \ + mkdir -p $$corpus; \ + for f in $(FUZZ_IOLOG_TIMING_CORPUS); do \ + cp $$f $$corpus; \ + done; \ + ./fuzz_iolog_timing -max_len=$(FUZZ_MAX_LEN) -runs=$(FUZZ_RUNS) $$corpus + pre-install: install: @@ -239,6 +292,8 @@ cppcheck: pvs-log-files: $(POBJS) +fuzz: run-fuzz_iolog_json run-fuzz_iolog_legacy run-fuzz_iolog_timing + check-fuzzer: $(FUZZ_PROGS) @if test X"$(cross_compiling)" != X"yes"; then \ if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ @@ -280,7 +335,8 @@ clean: -$(LIBTOOL) $(LTFLAGS) --mode=clean rm -f $(TEST_PROGS) $(FUZZ_PROGS) \ *.lo *.o *.la -rm -f *.i *.plog stamp-* core *.core core.* regress/*/*.out \ - regress/*/*.err + regress/*/*.err regress/corpus/iolog_json \ + regress/corpus/iolog_legacy regress/corpus/iolog_timing mostlyclean: clean @@ -294,7 +350,9 @@ realclean: distclean cleandir: realclean -.PHONY: clean mostlyclean distclean cleandir clobber realclean $(FUZZ_SEED_CORPUS) +.PHONY: clean mostlyclean distclean cleandir clobber realclean \ + $(FUZZ_SEED_CORPUS) run-fuzz_iolog_json run-fuzz_iolog_legacy \ + run-fuzz_iolog_timing # Autogenerated dependencies, do not modify check_iolog_json.lo: $(srcdir)/regress/iolog_json/check_iolog_json.c \ diff --git a/lib/logsrv/Makefile.in b/lib/logsrv/Makefile.in index cd21a34ea..9e714e400 100644 --- a/lib/logsrv/Makefile.in +++ b/lib/logsrv/Makefile.in @@ -148,6 +148,8 @@ cppcheck: pvs-log-files: $(POBJS) +fuzz: + check-fuzzer: check: check-fuzzer diff --git a/lib/util/Makefile.in b/lib/util/Makefile.in index 713a00fc9..1c713f96f 100644 --- a/lib/util/Makefile.in +++ b/lib/util/Makefile.in @@ -1,7 +1,7 @@ # # SPDX-License-Identifier: ISC # -# Copyright (c) 2011-2020 Todd C. Miller +# Copyright (c) 2011-2021 Todd C. Miller # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -116,6 +116,8 @@ FUZZ_PROGS = fuzz_sudo_conf FUZZ_SEED_CORPUS = ${FUZZ_PROGS:=_seed_corpus.zip} FUZZ_LIBS = @LIBS@ $(LIB_FUZZING_ENGINE) FUZZ_LDFLAGS = @LDFLAGS@ +FUZZ_MAX_LEN = 4096 +FUZZ_RUNS = 8192 # User and group ids the installed files should be "owned" by install_uid = 0 @@ -303,6 +305,23 @@ fuzz_sudo_conf_seed_corpus.zip: zip -j $@ $$tdir/*; \ rm -rf $$tdir +run-fuzz_sudo_conf: fuzz_sudo_conf + if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ + LC_ALL=C.UTF-8; export LC_ALL; \ + else \ + LC_ALL=C; export LC_ALL; \ + fi; \ + unset LANG || LANG=; \ + MALLOC_OPTIONS=S; export MALLOC_OPTIONS; \ + MALLOC_CONF="abort:true,junk:true"; export MALLOC_CONF; \ + umask 022; \ + corpus=regress/corpus/sudo_conf; \ + mkdir -p $$corpus; \ + for f in $(FUZZ_SUDO_CONF_CORPUS); do \ + cp $$f $$corpus; \ + done; \ + ./fuzz_sudo_conf -dict=$(srcdir)/regress/fuzz/fuzz_sudo_conf.dict -max_len=$(FUZZ_MAX_LEN) -runs=$(FUZZ_RUNS) $$corpus + pre-install: install: install-dirs @@ -345,6 +364,8 @@ cppcheck: pvs-log-files: $(POBJS) +fuzz: run-fuzz_sudo_conf + check-fuzzer: $(FUZZ_PROGS) @if test X"$(cross_compiling)" != X"yes"; then \ if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ @@ -465,6 +486,7 @@ clean: *.lo *.o *.la -rm -f *.i *.plog stamp-* core *.core core.* regress/*/*.out \ regress/*/*.err + -rm -rf regress/corpus/sudo_conf mostlyclean: clean @@ -479,7 +501,8 @@ realclean: distclean cleandir: realclean -.PHONY: clean mostlyclean distclean cleandir clobber realclean $(FUZZ_SEED_CORPUS) +.PHONY: clean mostlyclean distclean cleandir clobber realclean \ + $(FUZZ_SEED_CORPUS) run-fuzz_sudo_conf # Autogenerated dependencies, do not modify aix.lo: $(srcdir)/aix.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \ diff --git a/lib/zlib/Makefile.in b/lib/zlib/Makefile.in index 335f44e93..828486d93 100644 --- a/lib/zlib/Makefile.in +++ b/lib/zlib/Makefile.in @@ -161,6 +161,8 @@ pvs-log-files: pvs-studio: +fuzz: + check-fuzzer: check: check-fuzzer diff --git a/logsrvd/Makefile.in b/logsrvd/Makefile.in index a153ad20e..a001001b2 100644 --- a/logsrvd/Makefile.in +++ b/logsrvd/Makefile.in @@ -1,7 +1,7 @@ # # SPDX-License-Identifier: ISC # -# Copyright (c) 2019-2020 Todd C. Miller +# Copyright (c) 2019-2021 Todd C. Miller # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -106,6 +106,8 @@ FUZZ_PROGS = fuzz_logsrvd_conf FUZZ_SEED_CORPUS = ${FUZZ_PROGS:=_seed_corpus.zip} FUZZ_LIBS = $(LIBS) $(LIB_FUZZING_ENGINE) FUZZ_LDFLAGS = $(LDFLAGS) +FUZZ_MAX_LEN = 4096 +FUZZ_RUNS = 8192 # User and group IDs the installed files should be "owned" by install_uid = 0 @@ -175,6 +177,23 @@ fuzz_logsrvd_conf_seed_corpus.zip: zip -j $@ $$tdir/*; \ rm -rf $$tdir +run-fuzz_logsrvd_conf: fuzz_logsrvd_conf + if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ + LC_ALL=C.UTF-8; export LC_ALL; \ + else \ + LC_ALL=C; export LC_ALL; \ + fi; \ + unset LANG || LANG=; \ + MALLOC_OPTIONS=S; export MALLOC_OPTIONS; \ + MALLOC_CONF="abort:true,junk:true"; export MALLOC_CONF; \ + umask 022; \ + corpus=regress/corpus/logsrvd_conf; \ + mkdir -p $$corpus; \ + for f in $(FUZZ_LOGSRVD_CONF_CORPUS); do \ + cp $$f $$corpus; \ + done; \ + ./fuzz_logsrvd_conf -max_len=$(FUZZ_MAX_LEN) -runs=$(FUZZ_RUNS) $$corpus + pre-install: install: install-binaries @@ -217,6 +236,8 @@ pvs-log-files: $(POBJS) pvs-studio: $(POBJS) plog-converter $(PVS_LOG_OPTS) $(POBJS) +fuzz: run-fuzz_logsrvd_conf + check-fuzzer: $(FUZZ_PROGS) @if test X"$(cross_compiling)" != X"yes"; then \ if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ @@ -237,6 +258,7 @@ clean: -$(LIBTOOL) $(LTFLAGS) --mode=clean rm -f $(PROGS) $(FUZZ_PROGS) \ *.lo *.o *.la -rm -f *.i *.plog stamp-* core *.core core.* + -rm -rf regress/corpus/logsrvd_conf mostlyclean: clean @@ -250,7 +272,8 @@ realclean: distclean cleandir: realclean -.PHONY: clean mostlyclean distclean cleandir clobber realclean $(FUZZ_SEED_CORPUS) +.PHONY: clean mostlyclean distclean cleandir clobber realclean \ + $(FUZZ_SEED_CORPUS) run-fuzz_logsrvd_conf # Autogenerated dependencies, do not modify fuzz_logsrvd_conf.o: $(srcdir)/regress/fuzz/fuzz_logsrvd_conf.c \ diff --git a/plugins/audit_json/Makefile.in b/plugins/audit_json/Makefile.in index 02377b3a6..8d0357fc8 100644 --- a/plugins/audit_json/Makefile.in +++ b/plugins/audit_json/Makefile.in @@ -181,6 +181,8 @@ pvs-log-files: $(POBJS) pvs-studio: $(POBJS) plog-converter $(PVS_LOG_OPTS) $(POBJS) +fuzz: + check-fuzzer: check: check-fuzzer diff --git a/plugins/group_file/Makefile.in b/plugins/group_file/Makefile.in index 60337e788..0f86c5fe5 100644 --- a/plugins/group_file/Makefile.in +++ b/plugins/group_file/Makefile.in @@ -184,6 +184,8 @@ pvs-log-files: $(POBJS) pvs-studio: $(POBJS) plog-converter $(PVS_LOG_OPTS) $(POBJS) +fuzz: + check-fuzzer: check: check-fuzzer diff --git a/plugins/python/Makefile.in b/plugins/python/Makefile.in index b1cea6cf9..b46fdf7af 100644 --- a/plugins/python/Makefile.in +++ b/plugins/python/Makefile.in @@ -220,6 +220,8 @@ realclean: distclean cleandir: realclean +fuzz: + check-fuzzer: check: $(TEST_PROGS) check-fuzzer diff --git a/plugins/sample/Makefile.in b/plugins/sample/Makefile.in index e2109217e..a27e57103 100644 --- a/plugins/sample/Makefile.in +++ b/plugins/sample/Makefile.in @@ -179,6 +179,8 @@ pvs-log-files: $(POBJS) pvs-studio: $(POBJS) plog-converter $(PVS_LOG_OPTS) $(POBJS) +fuzz: + check-fuzzer: check: check-fuzzer diff --git a/plugins/sample_approval/Makefile.in b/plugins/sample_approval/Makefile.in index 7aed9d887..15485b18a 100644 --- a/plugins/sample_approval/Makefile.in +++ b/plugins/sample_approval/Makefile.in @@ -181,6 +181,8 @@ pvs-log-files: $(POBJS) pvs-studio: $(POBJS) plog-converter $(PVS_LOG_OPTS) $(POBJS) +fuzz: + check-fuzzer: check: check-fuzzer diff --git a/plugins/sudoers/Makefile.in b/plugins/sudoers/Makefile.in index dcb33fbe2..b98d82770 100644 --- a/plugins/sudoers/Makefile.in +++ b/plugins/sudoers/Makefile.in @@ -165,6 +165,8 @@ FUZZ_PROGS = fuzz_policy fuzz_sudoers fuzz_sudoers_ldif FUZZ_SEED_CORPUS = ${FUZZ_PROGS:=_seed_corpus.zip} FUZZ_LIBS = libparsesudoers.la @SUDOERS_LIBS@ $(LIB_FUZZING_ENGINE) FUZZ_LDFLAGS = @LDFLAGS@ +FUZZ_MAX_LEN = 4096 +FUZZ_RUNS = 8192 AUTH_OBJS = sudo_auth.lo @AUTH_OBJS@ @@ -404,6 +406,23 @@ fuzz_policy_seed_corpus.zip: zip -j $@ $$tdir/*; \ rm -rf $$tdir +run-fuzz_policy: fuzz_policy + if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ + LC_ALL=C.UTF-8; export LC_ALL; \ + else \ + LC_ALL=C; export LC_ALL; \ + fi; \ + unset LANG || LANG=; \ + MALLOC_OPTIONS=S; export MALLOC_OPTIONS; \ + MALLOC_CONF="abort:true,junk:true"; export MALLOC_CONF; \ + umask 022; \ + corpus=regress/corpus/policy; \ + mkdir -p $$corpus; \ + for f in $(FUZZ_POLICY_CORPUS); do \ + cp $$f $$corpus; \ + done; \ + ./fuzz_policy -dict=$(srcdir)/regress/fuzz/fuzz_policy.dict -max_len=$(FUZZ_MAX_LEN) -runs=$(FUZZ_RUNS) $$corpus + fuzz_sudoers_seed_corpus.zip: tdir=fuzz_sudoers.$$$$; \ mkdir $$tdir; \ @@ -413,6 +432,23 @@ fuzz_sudoers_seed_corpus.zip: zip -j $@ $$tdir/*; \ rm -rf $$tdir +run-fuzz_sudoers: fuzz_sudoers + if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ + LC_ALL=C.UTF-8; export LC_ALL; \ + else \ + LC_ALL=C; export LC_ALL; \ + fi; \ + unset LANG || LANG=; \ + MALLOC_OPTIONS=S; export MALLOC_OPTIONS; \ + MALLOC_CONF="abort:true,junk:true"; export MALLOC_CONF; \ + umask 022; \ + corpus=regress/corpus/sudoers; \ + mkdir -p $$corpus; \ + for f in $(FUZZ_SUDOERS_CORPUS); do \ + cp $$f $$corpus; \ + done; \ + ./fuzz_sudoers -dict=$(srcdir)/regress/fuzz/fuzz_sudoers.dict -max_len=$(FUZZ_MAX_LEN) -runs=$(FUZZ_RUNS) $$corpus + fuzz_sudoers_ldif_seed_corpus.zip: tdir=fuzz_sudoers_ldif.$$$$; \ mkdir $$tdir; \ @@ -422,6 +458,23 @@ fuzz_sudoers_ldif_seed_corpus.zip: zip -j $@ $$tdir/*; \ rm -rf $$tdir +run-fuzz_sudoers_ldif: fuzz_sudoers_ldif + if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ + LC_ALL=C.UTF-8; export LC_ALL; \ + else \ + LC_ALL=C; export LC_ALL; \ + fi; \ + unset LANG || LANG=; \ + MALLOC_OPTIONS=S; export MALLOC_OPTIONS; \ + MALLOC_CONF="abort:true,junk:true"; export MALLOC_CONF; \ + umask 022; \ + corpus=regress/corpus/sudoers_ldif; \ + mkdir -p $$corpus; \ + for f in $(FUZZ_SUDOERS_LDIF_CORPUS); do \ + cp $$f $$corpus; \ + done; \ + ./fuzz_sudoers_ldif -dict=$(srcdir)/regress/fuzz/fuzz_sudoers_ldif.dict -max_len=$(FUZZ_MAX_LEN) -runs=$(FUZZ_RUNS) $$corpus + GENERATED = gram.h gram.c toke.c def_data.c def_data.h getdate.c prologue: @@ -551,6 +604,8 @@ pvs-log-files: $(POBJS) pvs-studio: $(POBJS) plog-converter $(PVS_LOG_OPTS) $(POBJS) +fuzz: run-fuzz_policy run-fuzz_sudoers run-fuzz_sudoers_ldif + check-fuzzer: $(FUZZ_PROGS) @if test X"$(cross_compiling)" != X"yes"; then \ if locale -a 2>&1 | grep '^C.UTF-8$$' >/dev/null 2>&1; then \ @@ -741,7 +796,8 @@ clean: -rm -f *.i *.plog stamp-* core *.core core.* prologue regress/*/*.out \ regress/*/*.toke regress/*/*.err regress/*/*.json \ regress/*/*.ldif regress/*/*.ldif2sudo regress/*/*.sudo - -rm -rf regress/iolog_plugin/iolog + -rm -rf regress/iolog_plugin/iolog regress/corpus/policy \ + regress/corpus/sudoers regress/corpus/sudoers_ldif mostlyclean: clean @@ -759,7 +815,9 @@ realclean: distclean cleandir: realclean -.PHONY: clean mostlyclean distclean cleandir clobber realclean $(FUZZ_SEED_CORPUS) +.PHONY: clean mostlyclean distclean cleandir clobber realclean \ + $(FUZZ_SEED_CORPUS) run-fuzz_policy run-fuzz_sudoers \ + run-fuzz_sudoers_ldif # Autogenerated dependencies, do not modify afs.lo: $(authdir)/afs.c $(authdir)/sudo_auth.h $(devdir)/def_data.h \ diff --git a/plugins/system_group/Makefile.in b/plugins/system_group/Makefile.in index 161da8384..c570bf1dd 100644 --- a/plugins/system_group/Makefile.in +++ b/plugins/system_group/Makefile.in @@ -184,6 +184,8 @@ pvs-log-files: $(POBJS) pvs-studio: $(POBJS) plog-converter $(PVS_LOG_OPTS) $(POBJS) +fuzz: + check-fuzzer: check: check-fuzzer diff --git a/src/Makefile.in b/src/Makefile.in index d85c598d9..80574f674 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -265,6 +265,8 @@ pvs-log-files: $(POBJS) pvs-studio: $(POBJS) plog-converter $(PVS_LOG_OPTS) $(POBJS) +fuzz: + check-fuzzer: check: $(TEST_PROGS) check-fuzzer