capstone/suite/fuzz
billow 18b6b9138d fix fuzz 2023-04-14 00:36:14 +08:00
..
Makefile switched to next branch 2021-11-10 17:05:26 +01:00
README suite: move fuzz_hardness.c to suite/fuzz/ 2015-06-16 17:37:48 +08:00
README.md Fuzzit integration (#1520) 2019-07-25 09:06:52 +08:00
driverbin.c fuzz: refactor platforms.inc to platform.c 2019-04-13 15:22:20 +08:00
drivermc.c RISCV support ISRV32/ISRV64 (#1401) 2019-03-09 08:41:12 +08:00
fuzz_decode_platform.c fuzz: refactor platforms.inc to platform.c 2019-04-13 15:22:20 +08:00
fuzz_diff.c Use whole corpus for regression testing (#1302) 2018-12-11 09:33:31 +07:00
fuzz_disasm.c fuzz: refactor platforms.inc to platform.c 2019-04-13 15:22:20 +08:00
fuzz_disasm.options Integrate capstone with oss-fuzz (#1150) 2018-06-01 20:47:19 +08:00
fuzz_harness.c M680X: Target ready for pull request (#1034) 2017-10-21 21:44:36 +08:00
fuzz_llvm.cpp Use whole corpus for regression testing (#1302) 2018-12-11 09:33:31 +07:00
fuzzit.sh Fuzzit integration (#1520) 2019-07-25 09:06:52 +08:00
fuzzitid.txt Fuzzit integration (#1520) 2019-07-25 09:06:52 +08:00
onefile.c Avoids memory leak with fuzz driver (#1233) 2018-08-27 07:57:27 +07:00
platform.c fix fuzz 2023-04-14 00:36:14 +08:00
platform.h fuzz: refactor platforms.inc to platform.c 2019-04-13 15:22:20 +08:00

README.md

Fuzzing

Build the fuzz target

To build the fuzz target, you can simply run make with appropriate flags set :

ASAN_OPTIONS=detect_leaks=0 CXXFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" CFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" LDFLAGS="-fsanitize=address" make

You can replace address with another sanitizer : memory or undefined The fuzz target is then suite/fuzz/fuzz_bindisasm2

You can find this in travis configuration .travis.yml

Another way is to use oss-fuzz, see https://github.com/google/oss-fuzz/blob/master/projects/capstone/build.sh

Fuzz drivers

There are custom drivers :

  • driverbin.c : prints cstool command before running one input
  • drivermc.c : converts MC test data to raw binary data before running as many inputs as there are lines in a file
  • onefile.c : simple one file driver

For libfuzzer, the preferred main function is now to use linker option -fsanitize=fuzzer

Fuzzit integration

Travis will build the fuzz target with the different sanitizers. Then, Travis will launch sanity fuzzit jobs as part of continuous integration (for each of the sanitizers) The fuzzit target ids are stored in a configuration file fuzzitid.txt and used by fuzzit.sh