From 26beac163e1204050c54a21db224b6301ff69480 Mon Sep 17 00:00:00 2001 From: Joonatan Saarhelo Date: Sun, 26 May 2024 02:39:57 +0200 Subject: [PATCH] better fuzz.sh --- afl-fuzz/Cargo.toml | 6 +++++- afl-fuzz/fuzz.sh | 3 ++- afl-fuzz/src/check_input_size.rs | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 afl-fuzz/src/check_input_size.rs diff --git a/afl-fuzz/Cargo.toml b/afl-fuzz/Cargo.toml index f383b19f..c121475e 100644 --- a/afl-fuzz/Cargo.toml +++ b/afl-fuzz/Cargo.toml @@ -13,4 +13,8 @@ features = ["single_instruction_test"] [[bin]] name = "show_testcase" -path = "src/show_testcase.rs" \ No newline at end of file +path = "src/show_testcase.rs" + +[[bin]] +name = "check_input_size" +path = "src/check_input_size.rs" \ No newline at end of file diff --git a/afl-fuzz/fuzz.sh b/afl-fuzz/fuzz.sh index c785edb6..fbd01cdf 100644 --- a/afl-fuzz/fuzz.sh +++ b/afl-fuzz/fuzz.sh @@ -1 +1,2 @@ -cargo afl build --release && cargo afl fuzz -i in -o out ../target/release/afl-fuzz -g 10k \ No newline at end of file +export AFL_AUTORESUME=1 +cargo afl build --release && cargo afl fuzz -i in -o out -g $(cargo run --bin check_input_size) ../target/release/afl-fuzz \ No newline at end of file diff --git a/afl-fuzz/src/check_input_size.rs b/afl-fuzz/src/check_input_size.rs new file mode 100644 index 00000000..378e5ba1 --- /dev/null +++ b/afl-fuzz/src/check_input_size.rs @@ -0,0 +1,17 @@ +//! Finds out how many bytes of data have to be provided to build the mock state. + +use arbitrary::Arbitrary; +use vm2::{MockWorld, VirtualMachine}; + +fn main() { + let data = [2; 10000]; + let mut u = arbitrary::Unstructured::new(&data); + let _: VmAndWorld = u.arbitrary().unwrap(); + println!("{:?}", u.len()); +} + +#[derive(Arbitrary, Debug)] +struct VmAndWorld { + _vm: VirtualMachine, + _world: MockWorld, +}