From d4cf18d668badb8c972a988654f78c00451b6141 Mon Sep 17 00:00:00 2001 From: selsta Date: Fri, 26 Jun 2026 00:01:54 +0200 Subject: [PATCH] tests: fix local AFL fuzz target build --- Makefile | 4 ++-- tests/fuzz/fuzzer.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 7b2798bf8..434ae3a24 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ coverage: fuzz: mkdir -p $(builddir)/fuzz - cd $(builddir)/fuzz && cmake -D STATIC=ON -D SANITIZE=ON -D BUILD_TESTS=ON -D USE_LTO=OFF -D CMAKE_C_COMPILER=afl-gcc -D CMAKE_CXX_COMPILER=afl-g++ -D ARCH="x86-64" -D CMAKE_BUILD_TYPE=fuzz -D BUILD_TAG="linux-x64" $(topdir) && $(MAKE) + cd $(builddir)/fuzz && cmake -D STATIC=ON -D SANITIZE=ON -D BUILD_TESTS=ON -D USE_LTO=OFF -D CMAKE_C_COMPILER=afl-gcc -D CMAKE_CXX_COMPILER=afl-g++ -D ARCH="x86-64" -D CMAKE_BUILD_TYPE=fuzz -D BUILD_TAG="linux-x64" $(topdir) && $(MAKE) -C tests/fuzz clean: @echo "WARNING: Back-up your wallet if it exists within ./"$(deldirs)"!" ; \ @@ -116,4 +116,4 @@ clean-all: [ $$CONTINUE = "y" ] || [ $$CONTINUE = "Y" ] || (echo "Exiting."; exit 1;) rm -rf ./build -.PHONY: all cmake-debug debug debug-test debug-test-asan debug-asan debug-all cmake-release release release-test release-all clean +.PHONY: all cmake-debug debug debug-test debug-test-asan debug-asan debug-all cmake-release release release-test release-all fuzz clean diff --git a/tests/fuzz/fuzzer.cpp b/tests/fuzz/fuzzer.cpp index efe473bf0..c881f87c9 100644 --- a/tests/fuzz/fuzzer.cpp +++ b/tests/fuzz/fuzzer.cpp @@ -35,8 +35,8 @@ #ifndef OSSFUZZ -#if (!defined(__clang__) || (__clang__ < 5)) -static int __AFL_LOOP(int) +#ifndef __AFL_LOOP +static int monero_fuzz_loop(int) { static int once = 0; if (once) @@ -44,6 +44,8 @@ static int __AFL_LOOP(int) once = 1; return 1; } +#else +#define monero_fuzz_loop(n) __AFL_LOOP(n) #endif int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer) @@ -65,7 +67,7 @@ int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer) return ret; const std::string filename = argv[1]; - while (__AFL_LOOP(1000)) + while (monero_fuzz_loop(1000)) { ret = fuzzer.run(filename); if (ret)