Skip to content

Commit

Permalink
Allow setting __afl_persistent_loop argument (support for #433) (#437)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update afl/src/lib.rs

Co-authored-by: Samuel Moelius <[email protected]>

* Format

---------

Co-authored-by: Samuel Moelius <[email protected]>
Co-authored-by: Samuel Moelius <[email protected]>
  • Loading branch information
3 people authored Dec 16, 2023
1 parent 4ff57cc commit 331cb24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion afl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cargo-afl/AFLplusplus
Submodule AFLplusplus updated 55 files
+1 βˆ’1 .custom-format.py
+2 βˆ’2 README.md
+10 βˆ’0 TODO.md
+15 βˆ’17 afl-cmin
+50 βˆ’36 afl-cmin.bash
+0 βˆ’4 benchmark/COMPARISON
+9 βˆ’0 benchmark/COMPARISON.md
+59 βˆ’0 benchmark/README.md
+420 βˆ’0 benchmark/benchmark-results.jsonl
+1,445 βˆ’0 benchmark/benchmark.ipynb
+281 βˆ’0 benchmark/benchmark.py
+0 βˆ’42 benchmark/benchmark.sh
+53 βˆ’0 custom_mutators/examples/custom_post_run.c
+5 βˆ’0 custom_mutators/examples/example.py
+16 βˆ’4 docs/Changelog.md
+1 βˆ’1 docs/INSTALL.md
+4 βˆ’0 docs/afl-fuzz_approach.md
+3 βˆ’2 docs/custom_mutators.md
+4 βˆ’1 docs/tutorials.md
+4 βˆ’4 frida_mode/src/main.c
+12 βˆ’0 include/afl-fuzz.h
+9 βˆ’9 include/afl-mutations.h
+1 βˆ’1 include/config.h
+1 βˆ’0 include/envs.h
+15 βˆ’15 include/xxhash.h
+16 βˆ’8 instrumentation/afl-compiler-rt.o.c
+6 βˆ’2 instrumentation/afl-llvm-common.cc
+21 βˆ’19 instrumentation/cmplog-instructions-pass.cc
+1 βˆ’1 instrumentation/cmplog-routines-pass.cc
+1 βˆ’1 instrumentation/cmplog-switches-pass.cc
+1 βˆ’1 instrumentation/split-switches-pass.so.cc
+1 βˆ’1 nyx_mode/LIBNYX_VERSION
+1 βˆ’1 nyx_mode/QEMU-Nyx
+1 βˆ’1 nyx_mode/QEMU_NYX_VERSION
+1 βˆ’1 nyx_mode/libnyx
+1 βˆ’1 nyx_mode/packer
+19 βˆ’19 qemu_mode/libqasan/dlmalloc.c
+2 βˆ’2 qemu_mode/libqasan/malloc.c
+1 βˆ’1 qemu_mode/qemuafl
+29 βˆ’22 src/afl-cc.c
+25 βˆ’2 src/afl-common.c
+1 βˆ’2 src/afl-forkserver.c
+11 βˆ’0 src/afl-fuzz-bitmap.c
+3 βˆ’2 src/afl-fuzz-extras.c
+12 βˆ’0 src/afl-fuzz-mutators.c
+17 βˆ’15 src/afl-fuzz-one.c
+30 βˆ’0 src/afl-fuzz-python.c
+9 βˆ’5 src/afl-fuzz-redqueen.c
+18 βˆ’1 src/afl-fuzz-run.c
+6 βˆ’7 src/afl-fuzz-stats.c
+1 βˆ’1 src/afl-ld-lto.c
+1 βˆ’1 unicorn_mode/UNICORNAFL_VERSION
+1 βˆ’1 unicorn_mode/unicornafl
+18 βˆ’1 utils/aflpp_driver/aflpp_driver.c
+3 βˆ’3 utils/libtokencap/libtokencap.so.c

0 comments on commit 331cb24

Please sign in to comment.