-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuzz.sh
More file actions
executable file
·74 lines (62 loc) · 1.9 KB
/
fuzz.sh
File metadata and controls
executable file
·74 lines (62 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
set -euo pipefail
# Paths
INCLUDE_DIR="../../include"
SRC_DIR="../../src"
UTHASH_DIR="../../uthash"
LIB="../../src/.libs/libucl.a"
LIBUCL_ROOT="../.." # project root (adjust if needed)
# Compiler + flags
CC=clang
SAN_FLAGS="-O1 -g -fsanitize=address"
CFLAGS="$SAN_FLAGS -I${INCLUDE_DIR} -I${SRC_DIR} -I${UTHASH_DIR}"
# Usage helper
usage() {
echo "Usage: $0 {build|fuzz} [args...]"
echo
echo " build Rebuild libucl with sanitizers and compile fuzz targets"
echo " fuzz [options] Run fuzz_ucl_parser with options (default: -fork=8 -ignore_crashes=1 -use_value_profile=1)"
exit 1
}
# Ensure we’re in the right place
if [[ ! -f fuzz_ucl_parser.c ]]; then
echo "Run this script from the fuzzing-campaign-1 directory"
exit 1
fi
cmd="${1:-}"
shift || true
case "$cmd" in
build)
echo "[*] Rebuilding libucl with sanitizers..."
(
cd "$LIBUCL_ROOT"
make clean || true
export CC=clang
export CFLAGS="$SAN_FLAGS"
export CXXFLAGS="$SAN_FLAGS"
./configure
make -j$(nproc)
)
echo "[*] Building fuzz_ucl_parser..."
$CC -O1 -g \
-fsanitize=fuzzer,address \
-I${INCLUDE_DIR} -I${SRC_DIR} -I${UTHASH_DIR} \
fuzz_ucl_parser.c $LIB -o fuzz_ucl_parser
echo "[*] Building repro_min..."
$CC $CFLAGS fuzz_min.c $LIB -o repro_min
echo "[*] Building main_tester..."
$CC $CFLAGS main_tester.c $LIB -o main_tester
echo "[+] Build complete with ASan/UBSan instrumentation."
;;
fuzz)
echo "[*] Starting fuzzing..."
FUZZ_ARGS=("$@")
if [ ${#FUZZ_ARGS[@]} -eq 0 ]; then
FUZZ_ARGS=(-fork=8 -ignore_crashes=1 -use_value_profile=1 seed_corpus/ -dict=ucl.dict)
fi
./fuzz_ucl_parser "${FUZZ_ARGS[@]}"
;;
*)
usage
;;
esac