From: Aki Tuomi Date: Mon, 10 Nov 2025 07:39:57 +0000 (+0200) Subject: lib-var-expand: Add fuzzer for var_expand_program_create() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b597a7344446963f3660fc1d4ea02a21f7c52d51;p=thirdparty%2Fdovecot%2Fcore.git lib-var-expand: Add fuzzer for var_expand_program_create() --- diff --git a/src/lib-var-expand/Makefile.am b/src/lib-var-expand/Makefile.am index 3e4f49a57f..298c364745 100644 --- a/src/lib-var-expand/Makefile.am +++ b/src/lib-var-expand/Makefile.am @@ -67,3 +67,23 @@ test_libs = \ test_var_expand_SOURCE = test-var-expand.c test_var_expand_LDADD = $(test_libs) + +if USE_FUZZER +fuzz_programs = fuzz-var-expand + +nodist_EXTRA_fuzz_var_expand_SOURCES = force-cxx-linking.cxx + +fuzz_var_expand_CPPFLAGS = $(FUZZER_CPPFLAGS) +fuzz_var_expand_LDFLAGS = $(FUZZER_LDFLAGS) +fuzz_var_expand_SOURCES = fuzz-var-expand.c +fuzz_var_expand_LDADD = $(test_libs) +fuzz_var_expand_DEPENDENCIES = libvar_expand.la + +noinst_PROGRAMS += $(fuzz_programs) + +endif + +check-local: + for bin in $(test_programs); do \ + if ! $(RUN_TEST) ./$$bin; then exit 1; fi; \ + done diff --git a/src/lib-var-expand/fuzz-var-expand.c b/src/lib-var-expand/fuzz-var-expand.c new file mode 100644 index 0000000000..cae3f14dfd --- /dev/null +++ b/src/lib-var-expand/fuzz-var-expand.c @@ -0,0 +1,14 @@ +/* Copyright (c) 2025 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "fuzzer.h" +#include "var-expand.h" + +FUZZ_BEGIN_STR(const char *input) +{ + struct var_expand_program *program = NULL; + const char *error ATTR_UNUSED; + if (var_expand_program_create(input, &program, &error) == 0) + var_expand_program_free(&program); +} +FUZZ_END