From 66b2867ba253eae080a248aa67a4a8bc90e536a4 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Thu, 23 Mar 2023 11:02:18 +0100 Subject: [PATCH] Fix example fuzzers (#1171) * Fix example fuzzers * fmt --- fuzzers/nyx_libxml2_parallel/src/main.rs | 8 ++++---- libafl/src/bolts/llmp.rs | 2 +- libafl/src/corpus/testcase.rs | 1 - libafl_nyx/src/executor.rs | 2 +- libafl_nyx/src/helper.rs | 10 +++++----- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/fuzzers/nyx_libxml2_parallel/src/main.rs b/fuzzers/nyx_libxml2_parallel/src/main.rs index e7e9795577..14abb3e1e0 100644 --- a/fuzzers/nyx_libxml2_parallel/src/main.rs +++ b/fuzzers/nyx_libxml2_parallel/src/main.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use libafl::{ bolts::{ - core_affinity::Cores, + core_affinity::{CoreId, Cores}, launcher::Launcher, rands::{RandomSeed, StdRand}, shmem::{ShMemProvider, StdShMemProvider}, @@ -32,10 +32,10 @@ fn main() { let parent_cpu_id = cores.ids.first().expect("unable to get first core id"); // region: fuzzer start function - let mut run_client = |state: Option<_>, mut restarting_mgr, core_id: usize| { + let mut run_client = |state: Option<_>, mut restarting_mgr, core_id: CoreId| { // nyx shared dir, created by nyx-fuzz/packer/packer/nyx_packer.py let share_dir = Path::new("/tmp/nyx_libxml2/"); - let cpu_id = core_id.try_into().unwrap(); + let cpu_id = core_id.0.try_into().unwrap(); let parallel_mode = true; // nyx stuff let mut helper = NyxHelper::new( @@ -43,7 +43,7 @@ fn main() { cpu_id, true, parallel_mode, - Some(parent_cpu_id.id.try_into().unwrap()), + Some(parent_cpu_id.0.try_into().unwrap()), ) .unwrap(); let observer = diff --git a/libafl/src/bolts/llmp.rs b/libafl/src/bolts/llmp.rs index b2496bc1f5..853b1ac387 100644 --- a/libafl/src/bolts/llmp.rs +++ b/libafl/src/bolts/llmp.rs @@ -2201,7 +2201,7 @@ where while !self.is_shutting_down() { if current_milliseconds() > end_time { - on_new_msg_or_timeout(None).expect("An error occured in broker timeout. Exiting."); + on_new_msg_or_timeout(None).expect("An error occurred in broker timeout. Exiting."); end_time = current_milliseconds() + timeout; } diff --git a/libafl/src/corpus/testcase.rs b/libafl/src/corpus/testcase.rs index af2240beb2..5f5ee25767 100644 --- a/libafl/src/corpus/testcase.rs +++ b/libafl/src/corpus/testcase.rs @@ -8,7 +8,6 @@ use core::{ option::Option, time::Duration, }; - #[cfg(feature = "std")] use std::fs; diff --git a/libafl_nyx/src/executor.rs b/libafl_nyx/src/executor.rs index 8f756cb104..0e500b455f 100644 --- a/libafl_nyx/src/executor.rs +++ b/libafl_nyx/src/executor.rs @@ -73,7 +73,7 @@ where "FixMe: Nyx InvalidWriteToPayload handler is missing", )), NyxReturnValue::Error => Err(libafl::Error::illegal_state( - "Error: Nyx runtime error has occured...", + "Error: Nyx runtime error has occurred...", )), NyxReturnValue::IoError => { // todo! *stop_soon_p = 0 diff --git a/libafl_nyx/src/helper.rs b/libafl_nyx/src/helper.rs index 76530625af..ceb0da5315 100644 --- a/libafl_nyx/src/helper.rs +++ b/libafl_nyx/src/helper.rs @@ -30,7 +30,7 @@ pub enum NyxProcessType { CHILD, } impl NyxHelper { - /// create `NyxProcess` and do basic settings + /// Create [`NyxProcess`] and do basic settings /// It will convert instance to parent or child using `parent_cpu_id` when set`parallel_mode` /// will fail if initial connection takes more than 2 seconds pub fn new( @@ -49,7 +49,7 @@ impl NyxHelper { INIT_TIMEOUT, ) } - /// create `NyxProcess` and do basic settings + /// Create [`NyxProcess`] and do basic settings /// It will convert instance to parent or child using `parent_cpu_id` when set`parallel_mode` /// will fail if initial connection takes more than `initial_timeout` seconds pub fn with_initial_timeout( @@ -110,7 +110,7 @@ impl NyxHelper { match nyx_process.exec() { NyxReturnValue::Error => { nyx_process.shutdown(); - let msg = "Error: Nyx runtime error has occured..."; + let msg = "Error: Nyx runtime error has occurred..."; return Err(Error::illegal_state(msg)); } NyxReturnValue::IoError => { @@ -119,7 +119,7 @@ impl NyxHelper { } NyxReturnValue::Abort => { nyx_process.shutdown(); - let msg = "Error: Nyx abort occured..."; + let msg = "Error: Nyx abort occurred..."; return Err(Error::illegal_state(msg)); } _ => {} @@ -132,7 +132,7 @@ impl NyxHelper { }) } - /// set timeout + /// Set a timeout for Nyx pub fn set_timeout(mut self, time: Duration) { let sec: u8 = time .as_secs()