Commit b9b8451720 for bind
commit b9b8451720a7491a014aebbb7f213ea9015e7a30
Author: Michal Nowak <mnowak@isc.org>
Date: Wed Jun 3 17:03:54 2026 +0000
Fix AFL fuzzing build broken by -fcf-protection
Older AFL++ wrappers misinterpret -fcf-protection as a CFISAN request,
including when OSS-Fuzz selects the wrapper instead of BIND's AFL
backend.
Assisted-by: Claude:claude-opus-4-8
Assisted-by: Codex:gpt-6
diff --git a/fuzz/main.c b/fuzz/main.c
index 6c477df153..d9c928534b 100644
--- a/fuzz/main.c
+++ b/fuzz/main.c
@@ -139,7 +139,7 @@ main(int argc, char **argv) {
return 0;
}
-#elif __AFL_COMPILER
+#elif defined(ENABLE_AFL) && __AFL_COMPILER
int
main(int argc, char **argv) {
diff --git a/meson.build b/meson.build
index 63d2128b10..f76fdf45a5 100644
--- a/meson.build
+++ b/meson.build
@@ -35,6 +35,7 @@ fs = import('fs')
ss = import('sourceset')
cc = meson.get_compiler('c')
+afl_compiler = cc.get_define('__AFL_COMPILER') != ''
### Check if autoconf is mixed
if fs.exists(meson.project_source_root() / 'config.h')
@@ -208,7 +209,6 @@ if optimization != 'plain'
add_project_arguments(
cc.get_supported_arguments(
- '-fcf-protection=full',
'-fstack-clash-protection',
'-fstack-protector-strong',
@@ -217,6 +217,16 @@ if optimization != 'plain'
language: 'c',
)
+ # Older AFL++ wrappers mistake -fcf-protection for a CFISAN request and
+ # inject LTO flags; upstream fixed this in a9e8587ee86c (5.04a development).
+ # Apply the compatibility workaround to AFL compilers regardless of backend.
+ if not afl_compiler
+ add_project_arguments(
+ cc.get_supported_arguments('-fcf-protection=full'),
+ language: 'c',
+ )
+ endif
+
add_project_link_arguments(
cc.get_supported_link_arguments(
'-Wl,-z,noexecstack',