Commit dba319bcd9 for bind

commit dba319bcd915b99f0e74fbca2fca760cd9cca4c3
Author: Petr Špaček <pspacek@isc.org>
Date:   Wed Nov 4 09:35:58 2026 +0000

    Run bounded corpus replay in Meson tests

    Meson launched fuzz targets without corpus arguments: libFuzzer fuzzed
    without seeds until timeout, while AFL received no seed inputs. Replay
    the repository corpus so these tests reliably check for regressions.

    Assisted-by: Codex:gpt-6

diff --git a/fuzz/main.c b/fuzz/main.c
index fb1caf2d1a..0e8411bd9c 100644
--- a/fuzz/main.c
+++ b/fuzz/main.c
@@ -27,7 +27,8 @@

 #include "fuzz.h"

-#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+#if defined(FUZZING_REPLAY) || \
+	!defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)

 #include <dirent.h>

@@ -135,6 +136,10 @@ main(int argc, char **argv) {
 		return 1;
 	}

+	if (argc == 3 && strcmp(argv[1], "--corpus") == 0) {
+		return test_all_from(argv[2]);
+	}
+
 	if (argv[1] != NULL && strcmp(argv[1], "-d") == 0) {
 		debug = true;
 		argv++;
diff --git a/meson.build b/meson.build
index adf0cf61f4..861872a6a1 100644
--- a/meson.build
+++ b/meson.build
@@ -2057,9 +2057,34 @@ foreach name, sources : fuzz_binaries
         dependencies: fuzz_deps,
     )

+    corpus_dir = meson.project_source_root() / 'fuzz' / (name.substring(5) + '.in')
+    assert(
+        fs.is_dir(corpus_dir),
+        'missing fuzz corpus directory: ' + corpus_dir,
+    )
+    replay_bin = fuzz_bin
+    replay_args = ['--corpus', corpus_dir]
+    if fuzzing_backend_opt == 'libfuzzer'
+        replay_args = [corpus_dir, '-runs=0']
+    elif fuzzing_backend_opt in ['afl', 'oss-fuzz']
+        # Replay seeds without relying on the engine's command-line interface.
+        replay_bin = executable(
+            name + '_replay',
+            sources,
+            export_dynamic: true,
+            implicit_include_directories: true,
+            install: false,
+            c_args: ['-Wno-vla', '-DFUZZING_REPLAY=1'],
+            include_directories: test_inc,
+            sources: default_sanitize_options,
+            dependencies: fuzz_deps,
+        )
+    endif
+
     test(
         name,
-        fuzz_bin,
+        replay_bin,
+        args: replay_args,
         protocol: 'exitcode',
         suite: 'fuzz',
         timeout: 60,