Revert "Make harness function take mut ref (#1338)" (#1358)

This reverts commit fe6daecf0bb178cd19970ae81c797443fd8cd88f.
This commit is contained in:
Dongjia "toka" Zhang 2023-07-10 17:33:26 +02:00 committed by GitHub
parent 1ad1b7cb17
commit 109755208e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
86 changed files with 247 additions and 263 deletions

View File

@ -6,7 +6,7 @@ use libafl::{
};
fn main() {
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
if buf.len() > 0 && buf[0] == 'a' as u8 {

View File

@ -17,7 +17,7 @@ use std::path::PathBuf;
/* ANCHOR_END: use */
fn main() {
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
if buf.len() > 0 && buf[0] == 'a' as u8 {

View File

@ -28,7 +28,7 @@ fn signals_set(idx: usize) {
fn main() {
// The closure that we want to fuzz
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0); // set SIGNALS[0]

View File

@ -29,7 +29,7 @@ fn signals_set(idx: usize) {
fn main() {
// The closure that we want to fuzz
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0); // set SIGNALS[0]

View File

@ -34,7 +34,7 @@ fn signals_set(idx: usize) {
#[allow(clippy::similar_names, clippy::manual_assert)]
pub fn main() {
// The closure that we want to fuzz
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0);

View File

@ -49,7 +49,7 @@ pub fn main() {
let mut bytes = vec![];
// The closure that we want to fuzz
let mut harness = |input: &mut GramatronInput| {
let mut harness = |input: &GramatronInput| {
input.unparse(&mut bytes);
unsafe {
println!(">>> {}", std::str::from_utf8_unchecked(&bytes));

View File

@ -65,7 +65,7 @@ pub fn main() {
}
// The closure that we want to fuzz
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target_bytes = input.target_bytes();
let bytes = target_bytes.as_slice();

View File

@ -16,7 +16,7 @@ fn signals_set(idx: usize) {
#[allow(clippy::similar_names)]
pub fn main() -> Result<(), Error> {
// The closure that we want to fuzz
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0);

View File

@ -38,7 +38,7 @@ pub fn main() {
let mut bytes = vec![];
// The closure that we want to fuzz
let mut harness = |input: &mut NautilusInput| {
let mut harness = |input: &NautilusInput| {
input.unparse(&context, &mut bytes);
unsafe {
println!(">>> {}", std::str::from_utf8_unchecked(&bytes));

View File

@ -67,7 +67,7 @@ use slicemap::{HitcountsMapObserver, EDGES};
#[allow(clippy::too_many_lines)]
pub fn main() {
// The closure that we want to fuzz
let mut first_harness = |input: &mut BytesInput| {
let mut first_harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
if unsafe { inspect_first(buf.as_ptr(), buf.len()) } {
@ -76,7 +76,7 @@ pub fn main() {
ExitKind::Ok
}
};
let mut second_harness = |input: &mut BytesInput| {
let mut second_harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
if unsafe { inspect_second(buf.as_ptr(), buf.len()) } {

View File

@ -57,7 +57,7 @@ pub fn main() {
}
// The closure that we want to fuzz
let mut harness = |input: &mut EncodedInput| {
let mut harness = |input: &EncodedInput| {
decoded_bytes.clear();
encoder_decoder.decode(input, &mut decoded_bytes).unwrap();
unsafe {

View File

@ -44,7 +44,7 @@ pub fn fuzz() {
};
// The closure that we want to fuzz
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0);

View File

@ -37,7 +37,7 @@ pub fn main() {
};
// The closure that we want to fuzz
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0);

View File

@ -69,7 +69,7 @@ pub extern "C" fn external_current_millis() -> u64 {
#[no_mangle]
pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize {
// The closure that we want to fuzz
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0);

View File

@ -38,7 +38,7 @@ pub fn main() {
let mut shmem_provider = StdShMemProvider::new().unwrap();
unsafe { create_shmem_array() };
let map_ptr = unsafe { get_ptr() };
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
unsafe { c_harness(buf.as_ptr()) }

View File

@ -28,7 +28,7 @@ extern "C" {
#[allow(clippy::similar_names)]
pub fn main() {
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
unsafe { c_harness(buf.as_ptr()) }

View File

@ -39,7 +39,7 @@ pub fn main() {
};
// The closure that we want to fuzz
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0);

View File

@ -32,7 +32,7 @@ fn signals_set(idx: usize) {
#[allow(clippy::similar_names)]
pub fn main() {
// The closure that we want to fuzz
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0);

View File

@ -55,7 +55,7 @@ pub unsafe fn lib(main: extern "C" fn(i32, *const *const u8, *const *const u8) -
let options = parse_args();
let mut frida_harness = |input: &mut BytesInput| {
let mut frida_harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
let len = buf.len().to_string();
@ -87,7 +87,7 @@ pub unsafe fn lib(main: extern "C" fn(i32, *const *const u8, *const *const u8) -
#[allow(clippy::too_many_lines, clippy::too_many_arguments)]
unsafe fn fuzz(
options: &FuzzerOptions,
mut frida_harness: &dyn Fn(&mut BytesInput) -> ExitKind,
mut frida_harness: &dyn Fn(&BytesInput) -> ExitKind,
) -> Result<(), Error> {
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
let monitor = MultiMonitor::new(|s| println!("{s}"));

View File

@ -85,7 +85,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> {
unsafe extern "C" fn(data: *const u8, size: usize) -> i32,
> = lib.get(options.harness_function.as_bytes()).unwrap();
let mut frida_harness = |input: &mut BytesInput| {
let mut frida_harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
(target_func)(buf.as_ptr(), buf.len());

View File

@ -82,7 +82,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> {
unsafe extern "C" fn(data: *const u8, size: usize) -> i32,
> = lib.get(options.harness_function.as_bytes()).unwrap();
let mut frida_harness = |input: &mut BytesInput| {
let mut frida_harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
(target_func)(buf.as_ptr(), buf.len());

View File

@ -317,7 +317,7 @@ fn fuzz(
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -305,7 +305,7 @@ fn fuzz(
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let mut buf = target.as_slice();
let mut len = buf.len();

View File

@ -317,7 +317,7 @@ fn fuzz(
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let mut buf = target.as_slice();
let mut len = buf.len();

View File

@ -384,7 +384,7 @@ fn fuzz_binary(
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);
@ -609,7 +609,7 @@ fn fuzz_text(
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -249,7 +249,7 @@ pub fn LLVMFuzzerRunDriver(
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
harness_fn(buf.as_ptr(), buf.len());
@ -269,7 +269,7 @@ pub fn LLVMFuzzerRunDriver(
);
// Secondary harness due to mut ownership
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
harness_fn(buf.as_ptr(), buf.len());

View File

@ -133,7 +133,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -157,7 +157,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
#[cfg(feature = "crash")]

View File

@ -198,7 +198,7 @@ pub fn libafl_main() {
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -230,7 +230,7 @@ pub fn libafl_main() {
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -156,7 +156,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
#[cfg(feature = "crash")]

View File

@ -189,7 +189,7 @@ pub fn libafl_main() {
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -194,7 +194,7 @@ pub fn libafl_main() {
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -215,7 +215,7 @@ pub fn libafl_main() {
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -155,7 +155,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
#[cfg(feature = "crash")]

View File

@ -112,7 +112,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -115,7 +115,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -153,7 +153,7 @@ fn fuzz(
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -122,7 +122,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -135,7 +135,7 @@ pub fn libafl_main() {
let mut bytes = vec![];
// The closure that we want to fuzz
let mut harness = |input: &mut NautilusInput| {
let mut harness = |input: &NautilusInput| {
input.unparse(&context, &mut bytes);
libfuzzer_test_one_input(&bytes);
ExitKind::Ok

View File

@ -32,7 +32,7 @@ fn signals_set(idx: usize) {
#[allow(clippy::similar_names)]
fn input_generator() {
// The closure that produced the input for the generator
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
// The `yield_` switches execution context back to the loop in `main`.
// When `resume` is called, we return to this function.
yield_(input);

View File

@ -203,7 +203,7 @@ pub fn fuzz() {
let input_addr = emu.map_private(0, 4096, MmapPerms::ReadWrite).unwrap();
println!("Placing input at {input_addr:#x}");
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target
.as_slice()

View File

@ -210,7 +210,7 @@ pub fn fuzz() {
let input_addr = emu.map_private(0, 4096, MmapPerms::ReadWrite).unwrap();
println!("Placing input at {input_addr:#x}");
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target
.as_slice()

View File

@ -99,7 +99,7 @@ pub fn fuzz() {
let snap = emu.create_fast_snapshot(true);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let mut buf = target.as_slice();
let len = buf.len();

View File

@ -56,7 +56,7 @@ pub fn libafl_main() {
/// The actual fuzzer
fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Result<(), Error> {
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut PacketData| {
let mut harness = |input: &PacketData| {
let target = input.target_bytes();
let buf = target.as_slice();
libfuzzer_test_one_input(buf);

View File

@ -54,11 +54,11 @@ pub fn dump_registers<W: Write>(
writer: &mut BufWriter<W>,
ucontext: &ucontext_t,
) -> Result<(), std::io::Error> {
for reg in 0..31_usize {
for reg in 0..31 {
write!(
writer,
"x{:02}: 0x{:016x} ",
reg, ucontext.uc_mcontext.regs[reg]
reg, ucontext.uc_mcontext.regs[reg as usize]
)?;
if reg % 4 == 3 {
writeln!(writer)?;

View File

@ -2,8 +2,6 @@
//! too.)
use alloc::{rc::Rc, string::ToString};
#[cfg(feature = "std")]
use core::num::TryFromIntError;
use core::{
cell::RefCell,
fmt::{self, Debug, Display},
@ -1444,34 +1442,23 @@ impl<T: ShMem> std::io::Seek for ShMemCursor<T> {
std::io::SeekFrom::Start(s) => s,
std::io::SeekFrom::End(offset) => {
let map_len = self.inner.as_slice().len();
let signed_pos: i64 = map_len.try_into().map_err(|e: TryFromIntError| {
std::io::Error::new(std::io::ErrorKind::Other, e)
})?;
let effective = signed_pos.checked_add(offset).ok_or_else(|| {
std::io::Error::new(std::io::ErrorKind::Other, "Invalid offset")
})?;
i64::try_from(map_len).unwrap();
let signed_pos = i64::try_from(map_len).unwrap();
let effective = signed_pos.checked_add(offset).unwrap();
assert!(effective >= 0);
effective.try_into().map_err(|e: TryFromIntError| {
std::io::Error::new(std::io::ErrorKind::Other, e)
})?
effective.try_into().unwrap()
}
std::io::SeekFrom::Current(offset) => {
let current_pos = self.pos;
let signed_pos: i64 = current_pos.try_into().map_err(|e: TryFromIntError| {
std::io::Error::new(std::io::ErrorKind::Other, e)
})?;
let effective = signed_pos.checked_add(offset).ok_or_else(|| {
std::io::Error::new(std::io::ErrorKind::Other, "Invalid offset")
})?;
i64::try_from(current_pos).unwrap();
let signed_pos = i64::try_from(current_pos).unwrap();
let effective = signed_pos.checked_add(offset).unwrap();
assert!(effective >= 0);
effective.try_into().map_err(|e: TryFromIntError| {
std::io::Error::new(std::io::ErrorKind::Other, e)
})?
effective.try_into().unwrap()
}
};
self.pos = effective_new_pos
.try_into()
.map_err(|e: TryFromIntError| std::io::Error::new(std::io::ErrorKind::Other, e))?;
usize::try_from(effective_new_pos).unwrap();
self.pos = effective_new_pos as usize;
Ok(effective_new_pos)
}
}

View File

@ -128,7 +128,7 @@ where
// Execute the input; we cannot rely on the metadata already being present.
executor.observers_mut().pre_exec_all(state, &input)?;
let kind = executor.run_target(fuzzer, state, manager, &mut input.clone())?;
let kind = executor.run_target(fuzzer, state, manager, &input)?;
executor
.observers_mut()
.post_exec_all(state, &input, &kind)?;

View File

@ -1770,7 +1770,7 @@ mod tests {
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
let mut harness = |_buf: &mut BytesInput| ExitKind::Ok;
let mut harness = |_buf: &BytesInput| ExitKind::Ok;
let mut executor = InProcessExecutor::new(
&mut harness,
tuple_list!(),

View File

@ -52,7 +52,7 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
let ret = self.primary.run_target(fuzzer, state, mgr, input);
self.primary.post_run_reset();

View File

@ -323,7 +323,7 @@ where
_fuzzer: &mut Z,
_state: &mut Self::State,
_mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
use std::os::unix::prelude::ExitStatusExt;
@ -712,7 +712,7 @@ mod tests {
&mut NopFuzzer::new(),
&mut NopState::new(),
&mut mgr,
&mut BytesInput::new(b"test".to_vec()),
&BytesInput::new(b"test".to_vec()),
)
.unwrap();
}
@ -740,7 +740,7 @@ mod tests {
&mut NopFuzzer::new(),
&mut NopState::new(),
&mut mgr,
&mut BytesInput::new(b"test".to_vec()),
&BytesInput::new(b"test".to_vec()),
)
.unwrap();
}

View File

@ -68,7 +68,7 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
self.observers(); // update in advance
let observers = self.observers.get_mut();

View File

@ -429,7 +429,7 @@ where
_fuzzer: &mut Z,
_state: &mut Self::State,
_mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
let mut exit_kind = ExitKind::Ok;
@ -1091,7 +1091,7 @@ where
_fuzzer: &mut Z,
_state: &mut Self::State,
_mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
let mut exit_kind = ExitKind::Ok;

View File

@ -56,27 +56,22 @@ use crate::{
Error,
};
/// [`InProcessExecutor`] calls a target function as a mutable reference to a closure with a
/// mutable reference to the input as an argument to allow the harness to mutate the input
/// The process executor simply calls a target function, as mutable reference to a closure
pub type InProcessExecutor<'a, H, OT, S> = GenericInProcessExecutor<H, &'a mut H, OT, S>;
/// [`OwnedInProcessExecutor`] calls a boxed target function as a mutable reference
/// to a closure with a mutable reference to the input as an argument to allow the
/// harness to mutate the input
/// The process executor simply calls a target function, as boxed `FnMut` trait object
pub type OwnedInProcessExecutor<OT, S> = GenericInProcessExecutor<
dyn FnMut(&mut <S as UsesInput>::Input) -> ExitKind,
Box<dyn FnMut(&mut <S as UsesInput>::Input) -> ExitKind>,
dyn FnMut(&<S as UsesInput>::Input) -> ExitKind,
Box<dyn FnMut(&<S as UsesInput>::Input) -> ExitKind>,
OT,
S,
>;
/// The [`GenericInProcessExecutor`] calls a target function as a mutable reference
/// to a closure with a mutable reference to the input as an argument to allow the
/// harness to mutate the input, and returns afterwards
/// The inmem executor simply calls a target function, then returns afterwards.
#[allow(dead_code)]
pub struct GenericInProcessExecutor<H, HB, OT, S>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: UsesInput,
@ -92,7 +87,7 @@ where
impl<H, HB, OT, S> Debug for GenericInProcessExecutor<H, HB, OT, S>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: UsesInput,
@ -107,7 +102,7 @@ where
impl<H, HB, OT, S> UsesState for GenericInProcessExecutor<H, HB, OT, S>
where
H: ?Sized + FnMut(&mut S::Input) -> ExitKind,
H: ?Sized + FnMut(&S::Input) -> ExitKind,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: UsesInput,
@ -117,7 +112,7 @@ where
impl<H, HB, OT, S> UsesObservers for GenericInProcessExecutor<H, HB, OT, S>
where
H: ?Sized + FnMut(&mut S::Input) -> ExitKind,
H: ?Sized + FnMut(&S::Input) -> ExitKind,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: UsesInput,
@ -127,7 +122,7 @@ where
impl<EM, H, HB, OT, S, Z> Executor<EM, Z> for GenericInProcessExecutor<H, HB, OT, S>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
EM: UsesState<State = S>,
OT: ObserversTuple<S>,
@ -139,7 +134,7 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
self.handlers
.pre_run_target(self, fuzzer, state, mgr, input);
@ -151,9 +146,27 @@ where
}
}
impl<H, HB, OT, S> HasObservers for GenericInProcessExecutor<H, HB, OT, S>
where
H: FnMut(&S::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: UsesInput,
{
#[inline]
fn observers(&self) -> &OT {
&self.observers
}
#[inline]
fn observers_mut(&mut self) -> &mut OT {
&mut self.observers
}
}
impl<H, HB, OT, S> GenericInProcessExecutor<H, HB, OT, S>
where
H: FnMut(&mut <S as UsesInput>::Input) -> ExitKind + ?Sized,
H: FnMut(&<S as UsesInput>::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: HasSolutions + HasClientPerfMonitor + HasCorpus + HasExecutions,
@ -161,8 +174,7 @@ where
/// Create a new in mem executor.
/// Caution: crash and restart in one of them will lead to odd behavior if multiple are used,
/// depending on different corpus or state.
/// * `harness_fn` - the harness, executing the function. The harness may also mutate the
/// input.
/// * `harness_fn` - the harness, executing the function
/// * `observers` - the observers observing the target during execution
/// This may return an error on unix, if signal handler setup fails
pub fn new<CF, EM, OF, Z>(
@ -231,24 +243,6 @@ where
}
}
impl<H, HB, OT, S> HasObservers for GenericInProcessExecutor<H, HB, OT, S>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: UsesInput,
{
#[inline]
fn observers(&self) -> &OT {
&self.observers
}
#[inline]
fn observers_mut(&mut self) -> &mut OT {
&mut self.observers
}
}
/// The struct has [`InProcessHandlers`].
#[cfg(windows)]
pub trait HasInProcessHandlers {
@ -259,7 +253,7 @@ pub trait HasInProcessHandlers {
#[cfg(windows)]
impl<H, HB, OT, S> HasInProcessHandlers for GenericInProcessExecutor<H, HB, OT, S>
where
H: FnMut(&mut <S as UsesInput>::Input) -> ExitKind + ?Sized,
H: FnMut(&<S as UsesInput>::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: HasSolutions + HasClientPerfMonitor + HasCorpus + HasExecutions,
@ -1615,12 +1609,10 @@ extern "C" {
const ITIMER_REAL: libc::c_int = 0;
/// [`InProcessForkExecutor`] is an executor that forks the current process before each execution.
/// It is the same as [`InProcessForkExecutor`] except that it allows the harness input to be
/// mutated.
#[cfg(all(feature = "std", unix))]
pub struct InProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
OT: ObserversTuple<S>,
S: UsesInput,
SP: ShMemProvider,
@ -1636,7 +1628,7 @@ where
#[cfg(all(feature = "std", unix))]
pub struct TimeoutInProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
OT: ObserversTuple<S>,
S: UsesInput,
SP: ShMemProvider,
@ -1655,7 +1647,7 @@ where
#[cfg(all(feature = "std", unix))]
impl<'a, H, OT, S, SP> Debug for InProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
OT: ObserversTuple<S>,
S: UsesInput,
SP: ShMemProvider,
@ -1671,7 +1663,7 @@ where
#[cfg(all(feature = "std", unix))]
impl<'a, H, OT, S, SP> Debug for TimeoutInProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
OT: ObserversTuple<S>,
S: UsesInput,
SP: ShMemProvider,
@ -1700,7 +1692,7 @@ where
#[cfg(all(feature = "std", unix))]
impl<'a, H, OT, S, SP> UsesState for InProcessForkExecutor<'a, H, OT, S, SP>
where
H: ?Sized + FnMut(&mut S::Input) -> ExitKind,
H: ?Sized + FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
SP: ShMemProvider,
@ -1711,7 +1703,7 @@ where
#[cfg(all(feature = "std", unix))]
impl<'a, H, OT, S, SP> UsesState for TimeoutInProcessForkExecutor<'a, H, OT, S, SP>
where
H: ?Sized + FnMut(&mut S::Input) -> ExitKind,
H: ?Sized + FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
SP: ShMemProvider,
@ -1723,7 +1715,7 @@ where
impl<'a, EM, H, OT, S, SP, Z> Executor<EM, Z> for InProcessForkExecutor<'a, H, OT, S, SP>
where
EM: UsesState<State = S>,
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
OT: ObserversTuple<S>,
S: UsesInput,
SP: ShMemProvider,
@ -1736,7 +1728,7 @@ where
_fuzzer: &mut Z,
state: &mut Self::State,
_mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
unsafe {
self.shmem_provider.pre_fork()?;
@ -1791,7 +1783,7 @@ where
impl<'a, EM, H, OT, S, SP, Z> Executor<EM, Z> for TimeoutInProcessForkExecutor<'a, H, OT, S, SP>
where
EM: UsesState<State = S>,
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
OT: ObserversTuple<S>,
S: UsesInput,
SP: ShMemProvider,
@ -1804,7 +1796,7 @@ where
_fuzzer: &mut Z,
state: &mut Self::State,
_mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
unsafe {
self.shmem_provider.pre_fork()?;
@ -1893,7 +1885,7 @@ where
#[cfg(all(feature = "std", unix))]
impl<'a, H, OT, S, SP> InProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
OT: ObserversTuple<S>,
S: UsesInput + HasCorpus,
SP: ShMemProvider,
@ -1942,7 +1934,7 @@ where
#[cfg(all(feature = "std", unix))]
impl<'a, H, OT, S, SP> TimeoutInProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
S: UsesInput + HasCorpus,
OT: ObserversTuple<S>,
SP: ShMemProvider,
@ -2053,7 +2045,7 @@ where
#[cfg(all(feature = "std", unix))]
impl<'a, H, OT, S, SP> UsesObservers for InProcessForkExecutor<'a, H, OT, S, SP>
where
H: ?Sized + FnMut(&mut S::Input) -> ExitKind,
H: ?Sized + FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
SP: ShMemProvider,
@ -2064,7 +2056,7 @@ where
#[cfg(all(feature = "std", unix))]
impl<'a, H, OT, S, SP> UsesObservers for TimeoutInProcessForkExecutor<'a, H, OT, S, SP>
where
H: ?Sized + FnMut(&mut S::Input) -> ExitKind,
H: ?Sized + FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
SP: ShMemProvider,
@ -2075,7 +2067,7 @@ where
#[cfg(all(feature = "std", unix))]
impl<'a, H, OT, S, SP> HasObservers for InProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
S: UsesInput,
OT: ObserversTuple<S>,
SP: ShMemProvider,
@ -2094,7 +2086,7 @@ where
#[cfg(all(feature = "std", unix))]
impl<'a, H, OT, S, SP> HasObservers for TimeoutInProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind + ?Sized,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
S: UsesInput,
OT: ObserversTuple<S>,
SP: ShMemProvider,
@ -2222,7 +2214,7 @@ mod tests {
#[test]
fn test_inmem_exec() {
let mut harness = |_buf: &mut NopInput| ExitKind::Ok;
let mut harness = |_buf: &NopInput| ExitKind::Ok;
let mut in_process_executor = InProcessExecutor::<_, _, _> {
harness_fn: &mut harness,
@ -2230,13 +2222,13 @@ mod tests {
handlers: InProcessHandlers::nop(),
phantom: PhantomData,
};
let mut input = NopInput {};
let input = NopInput {};
in_process_executor
.run_target(
&mut NopFuzzer::new(),
&mut NopState::new(),
&mut NopEventManager::new(),
&mut input,
&input,
)
.unwrap();
}
@ -2256,7 +2248,7 @@ mod tests {
let provider = StdShMemProvider::new().unwrap();
let mut harness = |_buf: &mut NopInput| ExitKind::Ok;
let mut harness = |_buf: &NopInput| ExitKind::Ok;
let mut in_process_fork_executor = InProcessForkExecutor::<_, (), _, _> {
harness_fn: &mut harness,
shmem_provider: provider,
@ -2264,12 +2256,12 @@ mod tests {
handlers: InChildProcessHandlers::nop(),
phantom: PhantomData,
};
let mut input = NopInput {};
let input = NopInput {};
let mut fuzzer = NopFuzzer::new();
let mut state = NopState::new();
let mut mgr = SimpleEventManager::printing();
in_process_fork_executor
.run_target(&mut fuzzer, &mut state, &mut mgr, &mut input)
.run_target(&mut fuzzer, &mut state, &mut mgr, &input)
.unwrap();
}
}
@ -2311,7 +2303,7 @@ pub mod pybind {
) -> Self {
Self {
inner: OwnedInProcessExecutor::new(
Box::new(move |input: &mut BytesInput| {
Box::new(move |input: &BytesInput| {
Python::with_gil(|py| -> PyResult<()> {
let args = (PyBytes::new(py, input.bytes()),);
harness.call1(py, args)?;

View File

@ -3,7 +3,7 @@
pub mod inprocess;
pub use inprocess::InProcessExecutor;
#[cfg(all(feature = "std", feature = "fork", unix))]
pub use inprocess::{InProcessForkExecutor, TimeoutInProcessForkExecutor};
pub use inprocess::InProcessForkExecutor;
pub mod differential;
pub use differential::DiffExecutor;
@ -121,7 +121,7 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error>;
/// Wraps this Executor with the given [`ObserversTuple`] to implement [`HasObservers`].
@ -167,7 +167,7 @@ where
_fuzzer: &mut Z,
_state: &mut Self::State,
_mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
if input.target_bytes().as_slice().is_empty() {
Err(Error::empty("Input Empty"))
@ -186,8 +186,8 @@ mod test {
#[test]
fn nop_executor() {
let mut empty_input = BytesInput::new(vec![]);
let mut nonempty_input = BytesInput::new(vec![1u8]);
let empty_input = BytesInput::new(vec![]);
let nonempty_input = BytesInput::new(vec![1u8]);
let mut executor = NopExecutor {
phantom: PhantomData,
};
@ -200,7 +200,7 @@ mod test {
&mut fuzzer,
&mut state,
&mut NopEventManager::new(),
&mut empty_input,
&empty_input,
)
.unwrap_err();
executor
@ -208,7 +208,7 @@ mod test {
&mut fuzzer,
&mut state,
&mut NopEventManager::new(),
&mut nonempty_input,
&nonempty_input,
)
.unwrap();
}
@ -352,7 +352,7 @@ pub mod pybind {
fuzzer: &mut PythonStdFuzzer,
state: &mut Self::State,
mgr: &mut PythonEventManager,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
let ek = Python::with_gil(|py| -> PyResult<_> {
let ek: PythonExitKind = self
@ -475,7 +475,7 @@ pub mod pybind {
fuzzer: &mut PythonStdFuzzer,
state: &mut Self::State,
mgr: &mut PythonEventManager,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
unwrap_me_mut!(self.wrapper, e, { e.run_target(fuzzer, state, mgr, input) })
}

View File

@ -68,10 +68,9 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
let mut input = input.clone();
self.executor.run_target(fuzzer, state, mgr, &mut input)
self.executor.run_target(fuzzer, state, mgr, input)
}
}

View File

@ -385,7 +385,7 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
unsafe {
let data = &mut GLOBAL_STATE;
@ -460,7 +460,7 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
unsafe {
if self.batch_mode {
@ -533,7 +533,7 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
unsafe {
setitimer(ITIMER_REAL, &mut self.itimerval, null_mut());

View File

@ -28,7 +28,7 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
self.executor.run_target(fuzzer, state, mgr, input)
}

View File

@ -458,14 +458,14 @@ where
state: &mut Self::State,
executor: &mut E,
manager: &mut EM,
mut input: <Self::State as UsesInput>::Input,
input: <Self::State as UsesInput>::Input,
send_events: bool,
) -> Result<(ExecuteInputResult, Option<CorpusId>), Error>
where
E: Executor<EM, Self> + HasObservers<Observers = OT, State = Self::State>,
EM: EventFirer<State = Self::State>,
{
let exit_kind = self.execute_input(state, executor, manager, &mut input)?;
let exit_kind = self.execute_input(state, executor, manager, &input)?;
let observers = executor.observers();
self.scheduler.on_evaluation(state, &input, observers)?;
@ -503,9 +503,9 @@ where
state: &mut CS::State,
executor: &mut E,
manager: &mut EM,
mut input: <CS::State as UsesInput>::Input,
input: <CS::State as UsesInput>::Input,
) -> Result<CorpusId, Error> {
let exit_kind = self.execute_input(state, executor, manager, &mut input)?;
let exit_kind = self.execute_input(state, executor, manager, &input)?;
let observers = executor.observers();
// Always consider this to be "interesting"
@ -649,7 +649,7 @@ where
state: &mut CS::State,
executor: &mut E,
event_mgr: &mut EM,
input: &mut <CS::State as UsesInput>::Input,
input: &<CS::State as UsesInput>::Input,
) -> Result<ExitKind, Error>
where
E: Executor<EM, Self> + HasObservers<Observers = OT, State = CS::State>,
@ -688,7 +688,7 @@ where
state: &mut Self::State,
executor: &mut E,
event_mgr: &mut EM,
input: &mut <Self::State as UsesInput>::Input,
input: &<Self::State as UsesInput>::Input,
) -> Result<ExitKind, Error>;
}
@ -707,7 +707,7 @@ where
state: &mut CS::State,
executor: &mut E,
event_mgr: &mut EM,
input: &mut <CS::State as UsesInput>::Input,
input: &<CS::State as UsesInput>::Input,
) -> Result<ExitKind, Error> {
start_timer!(state);
executor.observers_mut().pre_exec_all(state, input)?;

View File

@ -502,7 +502,7 @@ mod tests {
let scheduler = RandScheduler::new();
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
let mut harness = |_buf: &mut BytesInput| ExitKind::Ok;
let mut harness = |_buf: &BytesInput| ExitKind::Ok;
let mut executor = InProcessExecutor::new(
&mut harness,
tuple_list!(),

View File

@ -1239,20 +1239,20 @@ impl CrossoverReplaceMutator {
}
/// Returns the first and last diff position between the given vectors, stopping at the min len
fn locate_diffs(this: &[u8], other: &[u8]) -> Result<(i64, i64), Error> {
fn locate_diffs(this: &[u8], other: &[u8]) -> (i64, i64) {
let mut first_diff: i64 = -1;
let mut last_diff: i64 = -1;
for (i, (this_el, other_el)) in this.iter().zip(other.iter()).enumerate() {
#[allow(clippy::cast_possible_wrap)]
if this_el != other_el {
if first_diff < 0 {
first_diff = i.try_into()?;
first_diff = i as i64;
}
last_diff = i.try_into()?;
last_diff = i as i64;
}
}
Ok((first_diff, last_diff))
(first_diff, last_diff)
}
/// Splice mutation for inputs with a bytes vector
@ -1285,7 +1285,7 @@ where
let mut counter: u32 = 0;
loop {
let (f, l) = locate_diffs(input.bytes(), other.bytes())?;
let (f, l) = locate_diffs(input.bytes(), other.bytes());
if f != l && f >= 0 && l >= 2 {
break (f as u64, l as u64);

View File

@ -1867,13 +1867,13 @@ mod tests {
#[test]
fn test_read_tokens() {
let _res = fs::remove_file("test.tkns");
let data = r#"
let data = r###"
# comment
token1@123="AAA"
token1="A\x41A"
"A\AA"
token2="B"
"#;
"###;
fs::write("test.tkns", data).expect("Unable to write test.tkns");
let tokens = Tokens::from_file("test.tkns").unwrap();
log::info!("Token file entries: {:?}", tokens.tokens());

View File

@ -148,8 +148,10 @@ where
for id in state.corpus().ids() {
let was_fuzzed = state.testcase(id)?.scheduled_count() > 0;
if !was_fuzzed {
let selection = Some(id);
state.metadata_mut::<EcoMetadata>()?.state = EcoState::Exploration;
return Ok(id);
#[allow(clippy::unnecessary_literal_unwrap)] // false positive
return Ok(selection.expect("Error in the algorithm, this cannot be None"));
}
}

View File

@ -122,7 +122,7 @@ where
let mut start = current_time();
let exit_kind = executor.run_target(fuzzer, state, mgr, &mut input.clone())?;
let exit_kind = executor.run_target(fuzzer, state, mgr, &input)?;
let mut total_time = if exit_kind == ExitKind::Ok {
current_time() - start
} else {
@ -158,7 +158,7 @@ where
executor.observers_mut().pre_exec_all(state, &input)?;
start = current_time();
let exit_kind = executor.run_target(fuzzer, state, mgr, &mut input.clone())?;
let exit_kind = executor.run_target(fuzzer, state, mgr, &input)?;
if exit_kind != ExitKind::Ok {
if !has_errors {
mgr.log(

View File

@ -302,7 +302,7 @@ where
) -> Result<usize, Error> {
executor.observers_mut().pre_exec_all(state, &input)?;
let exit_kind = executor.run_target(fuzzer, state, manager, &mut input.clone())?;
let exit_kind = executor.run_target(fuzzer, state, manager, &input)?;
let observer = executor
.observers()

View File

@ -354,7 +354,7 @@ where
mark_feature_time!(state, PerfFeature::PreExecObservers);
start_timer!(state);
let exit_kind = executor.run_target(fuzzer, state, manager, &mut input.clone())?;
let exit_kind = executor.run_target(fuzzer, state, manager, input)?;
mark_feature_time!(state, PerfFeature::TargetExecution);
*state.executions_mut() += 1;

View File

@ -276,14 +276,14 @@ where
push_stage.init(fuzzer, state, event_mgr, executor.observers_mut())?;
loop {
let mut input =
let input =
match push_stage.pre_exec(fuzzer, state, event_mgr, executor.observers_mut()) {
Some(Ok(next_input)) => next_input,
Some(Err(err)) => return Err(err),
None => break,
};
let exit_kind = fuzzer.execute_input(state, executor, event_mgr, &mut input)?;
let exit_kind = fuzzer.execute_input(state, executor, event_mgr, &input)?;
push_stage.post_exec(
fuzzer,

View File

@ -78,7 +78,7 @@ where
let base_hash = hasher.finish();
mark_feature_time!(state, PerfFeature::GetInputFromCorpus);
fuzzer.execute_input(state, executor, manager, &mut base)?;
fuzzer.execute_input(state, executor, manager, &base)?;
let observers = executor.observers();
let mut feedback = self.create_feedback(observers);
@ -106,7 +106,7 @@ where
let corpus_idx = if input.len() < before_len {
// run the input
let exit_kind = fuzzer.execute_input(state, executor, manager, &mut input)?;
let exit_kind = fuzzer.execute_input(state, executor, manager, &input)?;
let observers = executor.observers();
// let the fuzzer process this execution -- it's possible that we find something
@ -156,7 +156,7 @@ where
base.hash(&mut hasher);
let new_hash = hasher.finish();
if base_hash != new_hash {
let exit_kind = fuzzer.execute_input(state, executor, manager, &mut base)?;
let exit_kind = fuzzer.execute_input(state, executor, manager, &base)?;
let observers = executor.observers();
*state.executions_mut() += 1;
// assumption: this input should not be marked interesting because it was not

View File

@ -62,9 +62,9 @@ where
mark_feature_time!(state, PerfFeature::PreExecObservers);
start_timer!(state);
let exit_kind =
self.tracer_executor
.run_target(fuzzer, state, manager, &mut input.clone())?;
let exit_kind = self
.tracer_executor
.run_target(fuzzer, state, manager, &input)?;
mark_feature_time!(state, PerfFeature::TargetExecution);
*state.executions_mut() += 1;
@ -138,8 +138,7 @@ where
) -> Result<(), Error> {
// First run with the un-mutated input
let original_unmutated_input = state.corpus().cloned_input_for_id(corpus_idx)?;
let mut unmutated_input = state.corpus().cloned_input_for_id(corpus_idx)?;
let unmutated_input = state.corpus().cloned_input_for_id(corpus_idx)?;
if let Some(name) = &self.cmplog_observer_name {
if let Some(ob) = self
@ -157,19 +156,17 @@ where
self.tracer_executor
.observers_mut()
.pre_exec_all(state, &original_unmutated_input)?;
.pre_exec_all(state, &unmutated_input)?;
let exit_kind =
self.tracer_executor
.run_target(fuzzer, state, manager, &mut unmutated_input)?;
.run_target(fuzzer, state, manager, &unmutated_input)?;
*state.executions_mut() += 1;
self.tracer_executor.observers_mut().post_exec_all(
state,
&original_unmutated_input,
&exit_kind,
)?;
self.tracer_executor
.observers_mut()
.post_exec_all(state, &unmutated_input, &exit_kind)?;
// Second run with the mutated input
let mutated_input = match state.metadata_map().get::<TaintMetadata>() {
@ -195,9 +192,9 @@ where
.observers_mut()
.pre_exec_all(state, &mutated_input)?;
let exit_kind =
self.tracer_executor
.run_target(fuzzer, state, manager, &mut mutated_input.clone())?;
let exit_kind = self
.tracer_executor
.run_target(fuzzer, state, manager, &mutated_input)?;
*state.executions_mut() += 1;
@ -283,7 +280,7 @@ where
mark_feature_time!(state, PerfFeature::PreExecObservers);
start_timer!(state);
let exit_kind = executor.run_target(fuzzer, state, manager, &mut input.clone())?;
let exit_kind = executor.run_target(fuzzer, state, manager, &input)?;
mark_feature_time!(state, PerfFeature::TargetExecution);
*state.executions_mut() += 1;

View File

@ -385,13 +385,14 @@ impl Allocator {
metadatas.sort_by(|a, b| a.address.cmp(&b.address));
let mut offset_to_closest = i64::max_value();
let mut closest = None;
let ptr: i64 = ptr.try_into().unwrap();
for metadata in metadatas {
let address: i64 = metadata.address.try_into().unwrap();
let new_offset = if hint_base == metadata.address {
(ptr - address).abs()
(ptr as i64 - metadata.address as i64).abs()
} else {
std::cmp::min(offset_to_closest, (ptr - address).abs())
std::cmp::min(
offset_to_closest,
(ptr as i64 - metadata.address as i64).abs(),
)
};
if new_offset < offset_to_closest {
offset_to_closest = new_offset;

View File

@ -251,13 +251,14 @@ impl AsanErrors {
cs.set_skipdata(true).expect("failed to set skipdata");
let start_pc = error.pc - 4 * 5;
for insn in &*cs
for insn in cs
.disasm_count(
unsafe { std::slice::from_raw_parts(start_pc as *mut u8, 4 * 11) },
start_pc as u64,
11,
)
.expect("failed to disassemble instructions")
.iter()
{
if insn.address() as usize == error.pc {
output
@ -275,9 +276,7 @@ impl AsanErrors {
#[allow(clippy::non_ascii_literal)]
writeln!(output, "{:━^100}", " ALLOCATION INFO ").unwrap();
let fault_address: i64 = fault_address.try_into().unwrap();
let metadata_address: i64 = error.metadata.address.try_into().unwrap();
let offset: i64 = fault_address - (metadata_address + 0x1000);
let offset: i64 = fault_address as i64 - (error.metadata.address + 0x1000) as i64;
let direction = if offset > 0 { "right" } else { "left" };
writeln!(
output,
@ -506,13 +505,14 @@ impl AsanErrors {
cs.set_skipdata(true).expect("failed to set skipdata");
let start_pc = pc;
for insn in &*cs
for insn in cs
.disasm_count(
unsafe { std::slice::from_raw_parts(start_pc as *mut u8, 4 * 11) },
start_pc as u64,
11,
)
.expect("failed to disassemble instructions")
.iter()
{
if insn.address() as usize == pc {
output

View File

@ -150,7 +150,7 @@ impl CoverageRuntime {
; mov QWORD [rsp-0x98], rbx
// Load the previous_pc
; mov rax, QWORD prev_loc_ptr as _
; mov rax, QWORD prev_loc_ptr as *mut u64 as _
; mov rax, QWORD [rax]
// Calculate the edge id
@ -158,7 +158,7 @@ impl CoverageRuntime {
; xor rax, rbx
// Load the map byte address
; mov rbx, QWORD map_addr_ptr as _
; mov rbx, QWORD map_addr_ptr as *mut [u8; MAP_SIZE] as _
; add rax, rbx
// Update the map byte
@ -168,7 +168,7 @@ impl CoverageRuntime {
; mov BYTE [rax],bl
// Update the previous_pc value
; mov rax, QWORD prev_loc_ptr as _
; mov rax, QWORD prev_loc_ptr as *mut u64 as _
; mov ebx, WORD (h64 >> 1) as i32
; mov QWORD [rax], rbx

View File

@ -24,12 +24,10 @@ use crate::helper::{FridaInstrumentationHelper, FridaRuntimeTuple};
#[cfg(windows)]
use crate::windows_hooks::initialize;
/// The [`FridaInProcessExecutor`] is an [`Executor`] that executes the target in the
/// same process, usinig [`frida`](https://frida.re/) for binary-only instrumentation. It is
/// the same as [`FridaInProcessExecutor`] except it allows mutating the input
/// The [`FridaInProcessExecutor`] is an [`Executor`] that executes the target in the same process, usinig [`frida`](https://frida.re/) for binary-only instrumentation.
pub struct FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S::Input: HasTargetBytes,
S: UsesInput,
OT: ObserversTuple<S>,
@ -46,7 +44,7 @@ where
impl<'a, 'b, 'c, H, OT, RT, S> Debug for FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
S::Input: HasTargetBytes,
OT: ObserversTuple<S>,
@ -64,7 +62,7 @@ impl<'a, 'b, 'c, EM, H, OT, RT, S, Z> Executor<EM, Z>
for FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
EM: UsesState<State = S>,
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
S::Input: HasTargetBytes,
OT: ObserversTuple<S>,
@ -78,7 +76,7 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
self.helper.pre_exec(input)?;
if self.helper.stalker_enabled() {
@ -108,7 +106,7 @@ where
impl<'a, 'b, 'c, H, OT, RT, S> UsesObservers for FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
S::Input: HasTargetBytes,
@ -118,7 +116,7 @@ where
impl<'a, 'b, 'c, H, OT, RT, S> UsesState for FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
S::Input: HasTargetBytes,
@ -128,7 +126,7 @@ where
impl<'a, 'b, 'c, H, OT, RT, S> HasObservers for FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S::Input: HasTargetBytes,
S: UsesInput,
OT: ObserversTuple<S>,
@ -146,7 +144,7 @@ where
impl<'a, 'b, 'c, H, OT, S, RT> FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
S::Input: HasTargetBytes,
OT: ObserversTuple<S>,
@ -201,7 +199,7 @@ where
impl<'a, 'b, 'c, H, OT, RT, S> HasInProcessHandlers
for FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput + HasClientPerfMonitor + HasSolutions + HasCorpus + HasExecutions,
S::Input: HasTargetBytes,
OT: ObserversTuple<S>,

View File

@ -57,7 +57,7 @@ where
_fuzzer: &mut Z,
_state: &mut Self::State,
_mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
let input_owned = input.target_bytes();
let input = input_owned.as_slice();

View File

@ -395,7 +395,7 @@ impl AsanGiovese {
if self.snapshot_shadow {
let set = self.dirty_shadow.lock().unwrap();
for &page in &*set {
for &page in set.iter() {
let data = Self::get_shadow_page(emu, page).to_vec();
self.saved_shadow.insert(page, data);
}
@ -425,7 +425,7 @@ impl AsanGiovese {
if self.snapshot_shadow {
let mut set = self.dirty_shadow.lock().unwrap();
for &page in &*set {
for &page in set.iter() {
let original = self.saved_shadow.get(&page);
if let Some(data) = original {
let cur = Self::get_shadow_page(emu, page);
@ -472,7 +472,7 @@ pub fn init_with_asan(
|e: &str| "LD_PRELOAD=".to_string() + &asan_lib + " " + &e["LD_PRELOAD=".len()..];
let mut added = false;
for (k, v) in &mut *env {
for (k, v) in env.iter_mut() {
if k == "QEMU_SET_ENV" {
let mut new_v = vec![];
for e in v.split(',') {

View File

@ -102,8 +102,8 @@ where
if self.full_trace {
if DRCOV_IDS.lock().unwrap().as_ref().unwrap().len() > self.drcov_len {
let mut drcov_vec = Vec::<DrCovBasicBlock>::new();
for id in DRCOV_IDS.lock().unwrap().as_ref().unwrap() {
'pcs_full: for (pc, idm) in DRCOV_MAP.lock().unwrap().as_ref().unwrap() {
for id in DRCOV_IDS.lock().unwrap().as_ref().unwrap().iter() {
'pcs_full: for (pc, idm) in DRCOV_MAP.lock().unwrap().as_ref().unwrap().iter() {
let mut module_found = false;
for module in self.module_mapping.iter() {
let (range, (_, _)) = module;
@ -141,7 +141,7 @@ where
} else {
if DRCOV_MAP.lock().unwrap().as_ref().unwrap().len() > self.drcov_len {
let mut drcov_vec = Vec::<DrCovBasicBlock>::new();
'pcs: for (pc, _) in DRCOV_MAP.lock().unwrap().as_ref().unwrap() {
'pcs: for (pc, _) in DRCOV_MAP.lock().unwrap().as_ref().unwrap().iter() {
let mut module_found = false;
for module in self.module_mapping.iter() {
let (range, (_, _)) = module;

View File

@ -41,7 +41,7 @@ impl<'a> EasyElf<'a> {
#[must_use]
pub fn resolve_symbol(&self, name: &str, load_addr: GuestAddr) -> Option<GuestAddr> {
for sym in &self.elf.syms {
for sym in self.elf.syms.iter() {
if let Some(sym_name) = self.elf.strtab.get_at(sym.st_name) {
if sym_name == name {
return if sym.st_value == 0 {

View File

@ -739,10 +739,18 @@ impl Emulator {
envp.push(null());
unsafe {
#[cfg(emulation_mode = "usermode")]
qemu_user_init(argc, argv.as_ptr(), envp.as_ptr());
qemu_user_init(
argc,
argv.as_ptr() as *const *const u8,
envp.as_ptr() as *const *const u8,
);
#[cfg(emulation_mode = "systemmode")]
{
qemu_init(argc, argv.as_ptr(), envp.as_ptr());
qemu_init(
argc,
argv.as_ptr() as *const *const u8,
envp.as_ptr() as *const *const u8,
);
libc::atexit(qemu_cleanup_atexit);
libafl_qemu_sys::syx_snapshot_init();
}

View File

@ -21,7 +21,7 @@ use crate::{emu::Emulator, helper::QemuHelperTuple, hooks::QemuHooks};
pub struct QemuExecutor<'a, H, OT, QT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
@ -33,7 +33,7 @@ where
impl<'a, H, OT, QT, S> Debug for QemuExecutor<'a, H, OT, QT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
@ -48,7 +48,7 @@ where
impl<'a, H, OT, QT, S> QemuExecutor<'a, H, OT, QT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
@ -101,7 +101,7 @@ where
impl<'a, EM, H, OT, QT, S, Z> Executor<EM, Z> for QemuExecutor<'a, H, OT, QT, S>
where
EM: UsesState<State = S>,
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
@ -112,7 +112,7 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
let emu = Emulator::new_empty();
if self.first_exec {
@ -133,7 +133,7 @@ where
impl<'a, H, OT, QT, S> UsesState for QemuExecutor<'a, H, OT, QT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
S: UsesInput,
@ -143,7 +143,7 @@ where
impl<'a, H, OT, QT, S> UsesObservers for QemuExecutor<'a, H, OT, QT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
S: UsesInput,
@ -153,7 +153,7 @@ where
impl<'a, H, OT, QT, S> HasObservers for QemuExecutor<'a, H, OT, QT, S>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
@ -172,7 +172,7 @@ where
#[cfg(feature = "fork")]
pub struct QemuForkExecutor<'a, H, OT, QT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
@ -186,7 +186,7 @@ where
#[cfg(feature = "fork")]
impl<'a, H, OT, QT, S, SP> Debug for QemuForkExecutor<'a, H, OT, QT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
@ -203,7 +203,7 @@ where
#[cfg(feature = "fork")]
impl<'a, H, OT, QT, S, SP> QemuForkExecutor<'a, H, OT, QT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput + HasCorpus,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
@ -268,7 +268,7 @@ where
impl<'a, EM, H, OT, QT, S, Z, SP> Executor<EM, Z> for QemuForkExecutor<'a, H, OT, QT, S, SP>
where
EM: EventManager<InProcessForkExecutor<'a, H, OT, S, SP>, Z, State = S>,
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput + HasClientPerfMonitor + HasMetadata + HasExecutions,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
@ -280,7 +280,7 @@ where
fuzzer: &mut Z,
state: &mut Self::State,
mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
let emu = Emulator::new_empty();
if self.first_exec {
@ -302,7 +302,7 @@ where
#[cfg(feature = "fork")]
impl<'a, H, OT, QT, S, SP> UsesObservers for QemuForkExecutor<'a, H, OT, QT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
S: UsesInput,
@ -314,7 +314,7 @@ where
#[cfg(feature = "fork")]
impl<'a, H, OT, QT, S, SP> UsesState for QemuForkExecutor<'a, H, OT, QT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
S: UsesInput,
@ -326,7 +326,7 @@ where
#[cfg(feature = "fork")]
impl<'a, H, OT, QT, S, SP> HasObservers for QemuForkExecutor<'a, H, OT, QT, S, SP>
where
H: FnMut(&mut S::Input) -> ExitKind,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,

View File

@ -211,7 +211,7 @@ impl QemuSnapshotHelper {
{
let new_maps = self.new_maps.get_mut().unwrap();
for acc in &mut self.accesses {
for acc in self.accesses.iter_mut() {
unsafe { &mut (*acc.get()) }.dirty.retain(|page| {
if let Some(info) = self.pages.get_mut(page) {
// TODO avoid duplicated memcpy
@ -251,7 +251,7 @@ impl QemuSnapshotHelper {
self.reset_maps(emulator);
// This one is after that we remapped potential regions mapped at snapshot time but unmapped during execution
for acc in &mut self.accesses {
for acc in self.accesses.iter_mut() {
for page in unsafe { &(*acc.get()).dirty } {
for entry in self
.maps

View File

@ -193,7 +193,7 @@ where
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
(harness_bytes)(buf);

View File

@ -204,7 +204,7 @@ where
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// The wrapped harness function, calling out to the LLVM-style harness
let mut harness = |input: &mut BytesInput| {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
(harness_bytes)(buf);

View File

@ -165,7 +165,7 @@ mod observers {
let mut hasher = RandomState::with_seeds(0, 0, 0, 0).build_hasher();
for map in unsafe { &COUNTERS_MAPS } {
let slice = map.as_slice();
let ptr = slice.as_ptr();
let ptr = slice.as_ptr() as *const u8;
let map_size = slice.len() / core::mem::size_of::<u8>();
unsafe {
hasher.write(from_raw_parts(ptr, map_size));

View File

@ -22,11 +22,11 @@ pub unsafe extern "C" fn __sanitizer_cov_trace_pc_guard(guard: *mut u32) {
{
#[cfg(feature = "sancov_pcguard_edges")]
{
(EDGES_MAP_PTR).add(pos).write(1);
(EDGES_MAP_PTR as *mut u8).add(pos).write(1);
}
#[cfg(feature = "sancov_pcguard_hitcounts")]
{
let addr = (EDGES_MAP_PTR).add(pos);
let addr = (EDGES_MAP_PTR as *mut u8).add(pos);
let val = addr.read().wrapping_add(1);
addr.write(val);
}

View File

@ -54,7 +54,7 @@ where
_fuzzer: &mut Z,
_state: &mut Self::State,
_mgr: &mut EM,
input: &mut Self::Input,
input: &Self::Input,
) -> Result<ExitKind, Error> {
match &self.map {
Some(_) => {

View File

@ -208,7 +208,7 @@ fn postprocess(pda: &[Transition], stack_limit: usize) -> Automaton {
//let mut culled_pda_unique = HashSet::new();
for final_state in &finals {
for transition in pda {
for transition in pda.iter() {
if transition.dest == *final_state && transition.stack.len() > 0 {
blocklist.insert(transition.dest);
} else {
@ -267,7 +267,7 @@ fn postprocess(pda: &[Transition], stack_limit: usize) -> Automaton {
}
} else {
// Running FSA construction in exact approximation mode and postprocessing it like so
for transition in pda {
for transition in pda.iter() {
num_transition += 1;
let state = transition.source;
if state >= memoized.len() {