How to fuzz
You can fuzz the library using afl fuzzer.
- Install the
aflfuzzer.
wget https://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz && tar xvf afl-latest.tgz
cd afl*/ && make && sudo make install
echo "core" | sudo tee /proc/sys/kernel/core_pattern
- Write the
testcode insidetest/test_srcdirectory to fuzz all functions of a specific library.- Make sure the
filenamestarts withfuzz_followed by thelibraryname. - For example,
fuzz_stack_singly_linkedlist_int.c.
- Make sure the
- Start the fuzzer. You can control the fuzzing time using
FUZZ_TIMEvariable.
cd test/
make fuzz TEST_LIB=stack_singly_linkedlist_int FUZZ_TIME=20m
- It creates
test/test_build/<lib_name>/fuzz/directory and saves all fuzz related artifacts over there.
How to reproduce the crash
aflwrites all crashes insideout/crashes/directory.- Execute the fuzz binary with the test data.
- For example
cd test/test_build/stack_using_singly_linkedlist/fuzz/
./fuzz_stack_using_singly_linkedlist < out/crashes/id:000000,sig:06,src:000000,op:havoc,rep:64