Commit e55d9a2a67 for bind

commit e55d9a2a672902bdc6cfa33edb4d14fe1a8f23b4
Author: Michal Nowak <mnowak@isc.org>
Date:   Mon Aug 10 16:08:27 2026 +0000

    Check the AFL fuzzing main() for read errors

    The AFL variant of main() checked the result of fread() for being
    negative, but fread() returns a size_t, so read errors went unnoticed
    and the target was fed whatever the partially filled buffer happened to
    contain.  Check ferror() instead.

    Assisted-by: Claude:claude-opus-5

diff --git a/fuzz/main.c b/fuzz/main.c
index bac824f7dc..fb1caf2d1a 100644
--- a/fuzz/main.c
+++ b/fuzz/main.c
@@ -169,6 +169,7 @@ main(int argc, char **argv) {
 int
 main(int argc, char **argv) {
 	int ret;
+	size_t n;
 	unsigned char buf[64 * 1024];

 	ret = LLVMFuzzerInitialize(&argc, &argv);
@@ -182,12 +183,14 @@ main(int argc, char **argv) {
 #else  /* ifdef __AFL_LOOP */
 	{
 #endif /* ifdef __AFL_LOOP */
-		ret = fread(buf, 1, sizeof(buf), stdin);
-		if (ret < 0) {
-			return 0;
+		n = fread(buf, 1, sizeof(buf), stdin);
+		if (ferror(stdin) != 0) {
+			fprintf(stderr, "Failed to read from stdin: %s\n",
+				strerror(errno));
+			return 1;
 		}

-		LLVMFuzzerTestOneInput(buf, ret);
+		LLVMFuzzerTestOneInput(buf, n);
 	}

 	return 0;