Commit 1a69924bdc for bind

commit 1a69924bdce6db329d36652cc36940e5f9316c43
Author: Michal Nowak <mnowak@isc.org>
Date:   Tue Aug 11 09:10:18 2026 +0000

    Fix the fuzzer names and stale bits in FUZZING.md

    The AFL and LibFuzzer examples named the binaries after the test cases,
    but the build targets carry a "fuzz_" prefix, so neither command line
    worked; and the "CC=afl-clang-fast" in front of the AFL setup had no
    effect, because the cross file picks the compiler itself.

    While there, replace the description of the test case objects, which
    dates back to the autoconf build, with what a fuzzer is made of these
    days, mention what the non-fuzzing binaries accept on the command line,
    and use Markdown headings in a file that is served as Markdown.

    Assisted-by: Claude:claude-opus-5

diff --git a/fuzz/FUZZING.md b/fuzz/FUZZING.md
index 8c1765ee60..43a5654e14 100644
--- a/fuzz/FUZZING.md
+++ b/fuzz/FUZZING.md
@@ -11,7 +11,7 @@ See the COPYRIGHT file distributed with this work for additional
 information regarding copyright ownership.
 -->

-= Fuzzing
+# Fuzzing

 Building the fuzzers is controlled by two meson options:

@@ -22,21 +22,29 @@ Building the fuzzers is controlled by two meson options:
   `none` backend still builds the binaries (so that breaking a fuzzer is
   caught at build time), but they only run in the non-fuzzing mode below.

+The build targets are named `fuzz_<test_name>` (see `fuzz_binaries` in
+`fuzz/meson.build`), while the test cases of a fuzzer live in
+`fuzz/<test_name>.in/`.
+
 The tests in this directory can be operated in the following modes:

 * non-fuzzing (`-Dfuzzing-backend=none`) - the test just runs over all input
   located in the `<test_name>.in/` directory by compiling with the mock
   main.c that walks through the directory and runs
-  `LLVMFuzzerTestOneInput()` over the input files.  This is what
-  `meson test --suite fuzz` exercises.
+  `LLVMFuzzerTestOneInput()` over the input files.  Individual test cases
+  can be passed on the command line instead, and `-d` as the first argument
+  turns on the `debug` flag.  The binary fails if an input could not be read
+  or no test case ran, so that an incomplete or misnamed corpus cannot
+  silently pass.
 * AFL (`-Dfuzzing-backend=afl`) - `main.c` will either feed the stdin to
   `LLVMFuzzerTestOneInput()` or run the `__AFL_LOOP(10000)` if compiled with
-  `afl-clang-fast`.  You have to compile using an AFL wrapper, e.g.
-  `CC=afl-clang-fast`.  The simplest way is the bundled cross file:
+  `afl-clang-fast`.  You have to compile using an AFL wrapper; the bundled
+  cross file selects `afl-cc`, and meson refuses to configure the backend
+  with a compiler that is not one:

-      CC=afl-clang-fast meson setup --cross-file fuzz/afl.ini build-afl
+      meson setup --cross-file fuzz/afl.ini build-afl
       ninja -C build-afl
-      afl-fuzz -i fuzz/<test_name>.in -o findings -- ./build-afl/<test_name>
+      afl-fuzz -i fuzz/<test_name>.in -o findings -- ./build-afl/fuzz_<test_name>

 * LibFuzzer (`-Dfuzzing-backend=libfuzzer`) - `main.c` is disabled completely
   and the standard LibFuzzer mechanism feeds `LLVMFuzzerTestOneInput` with the
@@ -44,23 +52,40 @@ The tests in this directory can be operated in the following modes:

       meson setup --cross-file fuzz/libfuzzer.ini build-libfuzzer
       ninja -C build-libfuzzer
-      ./build-libfuzzer/<test_name> fuzz/<test_name>.in
+      ./build-libfuzzer/fuzz_<test_name> fuzz/<test_name>.in

 * OSS-Fuzz (`-Dfuzzing-backend=oss-fuzz`) - like LibFuzzer, but the
-  instrumentation and linking flags are supplied externally via
-  `-Doss-fuzz-args=...` (set from the OSS-Fuzz `$CFLAGS`/`$LIB_FUZZING_ENGINE`
-  environment).
+  instrumentation flags are supplied externally through `$CFLAGS` and
+  the engine linking arguments through `-Doss-fuzz-args=$LIB_FUZZING_ENGINE`.
+  The build recipe lives in `projects/bind9/` of the
+  https://github.com/google/oss-fuzz repository.
+
+`meson test --suite fuzz` replays the repository corpora with every backend.
+LibFuzzer uses `-runs=0`; AFL and OSS-Fuzz use separate standalone replay
+binaries. These tests terminate after replay rather than starting an
+unbounded fuzzing session.

 Note: with clang-based backends meson must be configured with
-`-Db_lundef=false` (the cross files above already set this).
+`-Db_lundef=false` (the cross files above already set this).  Configuring
+any backend also disables link time optimization of `named`, because LTO
+discards the sanitizer coverage sections the backends need.
+
+## Test Cases

-== Test Cases
+Each test case should be called descriptively.  `fuzz/<test_name>.c` must
+define `LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)` and
+`LLVMFuzzerInitialize()`; both are declared in `fuzz.h`.  Add the file,
+together with `main.c`, as a new `fuzz_<test_name>` entry of the
+`fuzz_binaries` dictionary in `fuzz/meson.build`, and put the sample inputs
+into `fuzz/<test_name>.in/`.

-Each test case should be called descriptively and the executable target must
-link `testcase.o` and `main.o` and the `test_case.c` must have a function
-`LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)`.
+The fuzz binaries link only `libisc` and `libdns`; they deliberately avoid the
+`libbindtest` test library (`fuzz_dns_qp` pulls in just the QP test helpers via
+`libtest_qp_dep`), so that a static build stays self-contained.

-== Adding more fuzzers
+## Adding more fuzzers

-To add a different fuzzer, `main.c` must be modified to include `main()` function
-for a specific fuzzer (or no function as is case with LibFuzzer).
+To add a different fuzzer, add its name to the `fuzzing-backend` choices in
+`meson.options`, handle it in the fuzzing section of the top-level
+`meson.build`, and add the `main()` function for that fuzzer to `main.c` (or
+no function, as is the case with LibFuzzer).