]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-var-expand: Add fuzzer for var_expand_program_create()
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 10 Nov 2025 07:39:57 +0000 (09:39 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 11 Nov 2025 10:17:51 +0000 (10:17 +0000)
src/lib-var-expand/Makefile.am
src/lib-var-expand/fuzz-var-expand.c [new file with mode: 0644]

index 3e4f49a57f254816531ec21ac680e902018ffdb4..298c364745c2bf530e2a9a37a47376f70fb5d329 100644 (file)
@@ -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 (file)
index 0000000..cae3f14
--- /dev/null
@@ -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