From 331cb2414fb6203f04b71319c27cdaf9c6347cf6 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sat, 16 Dec 2023 11:59:22 +0100 Subject: [PATCH] Allow setting `__afl_persistent_loop` argument (support for #433) (#437) * add AFL_FUZZER_LOOPCOUNT support * update AFL++ to support the env * error on parsing * update afl++ commit id * Update afl/src/lib.rs Co-authored-by: Samuel Moelius <35515885+smoelius@users.noreply.github.com> * Update afl/src/lib.rs Co-authored-by: Samuel Moelius <35515885+smoelius@users.noreply.github.com> * Format --------- Co-authored-by: Samuel Moelius <35515885+smoelius@users.noreply.github.com> Co-authored-by: Samuel Moelius --- afl/src/lib.rs | 11 ++++++++++- cargo-afl/AFLplusplus | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/afl/src/lib.rs b/afl/src/lib.rs index 9d0e52848..836e83bc7 100644 --- a/afl/src/lib.rs +++ b/afl/src/lib.rs @@ -5,6 +5,7 @@ // you may not use this file except in compliance with the License. // See `LICENSE` in this repository. +use std::env; use std::io::{self, Read}; use std::panic; @@ -68,10 +69,18 @@ where let mut input = vec![]; + let loop_count = if let Ok(value) = env::var("AFL_FUZZER_LOOPCOUNT") { + value + .parse() + .expect("Failed to parse environment variable to a number") + } else { + usize::MAX + }; + // initialize forkserver there unsafe { __afl_manual_init() }; - while unsafe { __afl_persistent_loop(1000) } != 0 { + while unsafe { __afl_persistent_loop(loop_count) } != 0 { // get the testcase from the fuzzer let input_ref = if unsafe { __afl_fuzz_ptr.is_null() } { // in-memory testcase delivery is not enabled diff --git a/cargo-afl/AFLplusplus b/cargo-afl/AFLplusplus index 7e67dc9d6..ca0c9f6d1 160000 --- a/cargo-afl/AFLplusplus +++ b/cargo-afl/AFLplusplus @@ -1 +1 @@ -Subproject commit 7e67dc9d6938aadef19d5697a448cdf15a50172f +Subproject commit ca0c9f6d1797bac121996c3b2ac50423f6e67b8f