Skip to content

Commit 56730ca

Browse files
committed
delete_nonreduced_fuzz_inputs: also reduce with afl-cmin
1 parent 75c040f commit 56730ca

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

delete_nonreduced_fuzz_inputs.sh

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ wget https://apt.llvm.org/llvm.sh && chmod +x ./llvm.sh
2727
./llvm.sh $LLVM_VERSION all
2828
ln -s $(which llvm-symbolizer-$LLVM_VERSION) /usr/bin/llvm-symbolizer
2929

30+
git clone --branch stable https://github.com/AFLplusplus/AFLplusplus
31+
make -C AFLplusplus LLVM_CONFIG=llvm-config-$LLVM_VERSION PERFORMANCE=1 install -j$(nproc)
32+
3033
git clone --depth=1 https://github.com/bitcoin-core/qa-assets.git
3134
(
3235
cd qa-assets
@@ -42,10 +45,34 @@ git clone --depth=1 https://github.com/bitcoin/bitcoin.git
4245

4346
./autogen.sh
4447

48+
echo "Adding reduced seeds with afl-cmin"
49+
50+
./configure LDFLAGS="-fuse-ld=lld" CC=afl-clang-fast CXX=afl-clang-fast++ --enable-fuzz
51+
make clean
52+
make -j $(nproc)
53+
54+
WRITE_ALL_FUZZ_TARGETS_AND_ABORT="/tmp/a" "./src/test/fuzz/fuzz" || true
55+
readarray FUZZ_TARGETS < "/tmp/a"
56+
for fuzz_target in ${FUZZ_TARGETS[@]}; do
57+
if [ -d "../all_inputs/$fuzz_target" ]; then
58+
mkdir --parents ../qa-assets/"${FUZZ_INPUTS_DIR}"/$fuzz_target
59+
# Allow timeouts and crashes with "-A", "-T all" to use all available cores
60+
FUZZ=$fuzz_target afl-cmin -T all -A -i ../all_inputs/$fuzz_target -o ../qa-assets/"${FUZZ_INPUTS_DIR}"/$fuzz_target -- ./src/test/fuzz/fuzz
61+
else
62+
echo "No input corpus for $fuzz_target (ignoring)"
63+
fi
64+
done
65+
66+
(
67+
cd ../qa-assets
68+
git add "${FUZZ_INPUTS_DIR}"
69+
git commit -m "Reduced inputs for afl-cmin"
70+
)
71+
4572
for sanitizer in {"fuzzer","fuzzer,address,undefined,integer"}; do
4673
echo "Adding reduced seeds for sanitizer=${sanitizer}"
4774

48-
./configure CC=clang-$LLVM_VERSION CXX=clang++-$LLVM_VERSION --enable-fuzz --with-sanitizers="${sanitizer}"
75+
./configure LDFLAGS="-fuse-ld=lld" CC=clang-$LLVM_VERSION CXX=clang++-$LLVM_VERSION --enable-fuzz --with-sanitizers="${sanitizer}"
4976
make clean
5077
make -j $(nproc)
5178

0 commit comments

Comments
 (0)