Files
Build-System/fuzz/run.sh
T
faumaray 2dc0263e7b
VoidBuildSystem CI / signing-openssl-gcc16 (push) Successful in 1m37s
VoidBuildSystem CI / sanitizers-gcc16 (push) Canceled after 3m5s
VoidBuildSystem CI / fuzz-clang (push) Canceled after 1m29s
VoidBuildSystem CI / build-and-test-gcc16 (push) Canceled after 6m20s
fuzz: fall back to the newest C++ standard clang accepts
2026-12-05 14:32:12 +03:00

39 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Coverage-guided fuzzing of the standalone parsers with Clang/libFuzzer.
# Usage: VOID_INCLUDE_DIR=/path/to/VoidLibrary/include fuzz/run.sh [seconds] [extra libFuzzer args...]
set -euo pipefail
root="$(cd "$(dirname "$0")/.." && pwd)"
seconds="${1:-60}"
shift || true
: "${VOID_INCLUDE_DIR:?set VOID_INCLUDE_DIR to the VoidLibrary include directory}"
out="${FUZZ_OUT:-$root/build/fuzz}"
corpus="$out/corpus"
mkdir -p "$out" "$corpus"
if [ -d "$root/fuzz/seeds" ]; then
cp -n "$root/fuzz/seeds/"* "$corpus/" 2>/dev/null || true
fi
# Use the newest C++ standard the installed Clang accepts (older distributions stop at
# C++23, spelled c++2b there).
std_flag="${VBS_FUZZ_STD:-}"
if [ -z "$std_flag" ]; then
for candidate in c++26 c++2b c++23; do
if clang++ "-std=$candidate" -fsyntax-only -x c++ /dev/null >/dev/null 2>&1; then
std_flag="$candidate"
break
fi
done
fi
: "${std_flag:?clang++ accepts none of c++26/c++2b/c++23}"
echo "fuzzing with -std=$std_flag"
clang++ "-std=$std_flag" -O1 -g -fsanitize=fuzzer,address,undefined \
-fno-omit-frame-pointer \
-I"$root/include" -I"$root/recipes" -I"$VOID_INCLUDE_DIR" \
"$root/fuzz/fuzz_parsers.cpp" -o "$out/fuzz_parsers"
exec "$out/fuzz_parsers" -max_total_time="$seconds" -max_len=65536 "$corpus" "$@"