about fuzz testing with 9.16.27
When I try to build with fuzz support with 9.16.27 on fedora35, I could pass configuring with the command line:
$ ./configure --prefix=/usr/local/bind-9.16.27 --with-fuzzing=afl CC=afl-clang-fast
though it output "Unrecognized options",
...
Compiler: afl-clang-fast
clang version 13.0.0 (Fedora 13.0.0-3.fc35)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Unrecognized options:
--with-fuzzing
-------------------------------------------------------------------------------
For more detail, use --enable-full-report.
===============================================================================
continue to make, I met some error information,
...
afl-clang-fast -include /home/sun/bind-9.16.27/config.h -I/home/sun/bind-9.16.27 -I.. -I. -I.. -I/home/sun/bind-9.16.27/lib/dns/include -I../lib/dns/include -I/home/sun/bind-9.16.27/lib/isc/include -I../lib/isc -I../lib/isc/include -I../lib/isc/unix/include -I../lib/isc/pthreads/include -DOPENSSL_SUPPRESS_DEPRECATED -DFUZZDIR=\"/home/sun/bind-9.16.27/fuzz\" -g -O2 -pthread -fPIC -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -Wno-missing-field-initializers -fno-strict-aliasing -c main.c
main.c:130:9: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]
while (__AFL_LOOP(10000)) { /* only works with afl-clang-fast */
^
<command line>:15:88: note: expanded from here
#define __AFL_LOOP(_A) ({ static volatile char *_B __attribute__((used)); _B = (char*)"##SIG_AFL_PERSISTENT##"; __attribute__((visibility("default"))) int _L(unsigned int) __asm__("__afl_persistent_loop"); _L(_A); })
^
main.c:130:9: warning: variable '_B' set but not used [-Wunused-but-set-variable]
<command line>:15:49: note: expanded from here
#define __AFL_LOOP(_A) ({ static volatile char *_B __attribute__((used)); _B = (char*)"##SIG_AFL_PERSISTENT##"; __attribute__((visibility("default"))) int _L(unsigned int) __asm__("__afl_persistent_loop"); _L(_A); })
^
2 warnings generated.
afl-clang-fast -g -O2 -pthread -fPIC -Wl,--export-dynamic -o dns_name_fromtext_target \
dns_name_fromtext_target.o main.o ../lib/dns/libdns.a -llmdb -lmaxminddb ../lib/isc/libisc.a -lssl -lcrypto -ljson-c -lxml2 -lz -luv
afl-clang-fast -include /home/sun/bind-9.16.27/config.h -I/home/sun/bind-9.16.27 -I.. -I. -I.. -I/home/sun/bind-9.16.27/lib/dns/include -I../lib/dns/include -I/home/sun/bind-9.16.27/lib/isc/include -I../lib/isc -I../lib/isc/include -I../lib/isc/unix/include -I../lib/isc/pthreads/include -DOPENSSL_SUPPRESS_DEPRECATED -DFUZZDIR=\"/home/sun/bind-9.16.27/fuzz\" -g -O2 -pthread -fPIC -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -Wno-missing-field-initializers -fno-strict-aliasing -c dns_rdata_fromwire_text.c
afl-clang-fast -g -O2 -pthread -fPIC -Wl,--export-dynamic -o dns_rdata_fromwire_text \
dns_rdata_fromwire_text.o main.o ../lib/dns/libdns.a -llmdb -lmaxminddb ../lib/isc/libisc.a -lssl -lcrypto -ljson-c -lxml2 -lz -luv
/usr/bin/ld: dns_rdata_fromwire_text.o: in function `LLVMFuzzerTestOneInput':
/home/sun/bind-9.16.27/fuzz/dns_rdata_fromwire_text.c:130: undefined reference to `debug'
/usr/bin/ld: /home/sun/bind-9.16.27/fuzz/dns_rdata_fromwire_text.c:175: undefined reference to `debug'
/usr/bin/ld: dns_rdata_fromwire_text.o: in function `nullmsg':
/home/sun/bind-9.16.27/fuzz/dns_rdata_fromwire_text.c:54: undefined reference to `debug'
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:471: dns_rdata_fromwire_text] Error 1
make[1]: Leaving directory '/home/sun/bind-9.16.27/fuzz'
make: *** [Makefile:93: subdirs] Error 1
And the afl was installed from fedora' repo with dnf.
dnf -y install american-fuzzy-lop-clang
On RockyLinux 8.5, I met the same problem, except the AFL is installed with the source code, version is AFLplusplus 3.14c.
Sorry if I missed something. Thanks for your help !