Fix example fuzzers (#1171)

* Fix example fuzzers

* fmt
This commit is contained in:
Dominik Maier 2023-03-23 11:02:18 +01:00 committed by GitHub
parent a659dd821c
commit 66b2867ba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 12 deletions

View File

@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};
use libafl::{ use libafl::{
bolts::{ bolts::{
core_affinity::Cores, core_affinity::{CoreId, Cores},
launcher::Launcher, launcher::Launcher,
rands::{RandomSeed, StdRand}, rands::{RandomSeed, StdRand},
shmem::{ShMemProvider, StdShMemProvider}, shmem::{ShMemProvider, StdShMemProvider},
@ -32,10 +32,10 @@ fn main() {
let parent_cpu_id = cores.ids.first().expect("unable to get first core id"); let parent_cpu_id = cores.ids.first().expect("unable to get first core id");
// region: fuzzer start function // 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 // nyx shared dir, created by nyx-fuzz/packer/packer/nyx_packer.py
let share_dir = Path::new("/tmp/nyx_libxml2/"); 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; let parallel_mode = true;
// nyx stuff // nyx stuff
let mut helper = NyxHelper::new( let mut helper = NyxHelper::new(
@ -43,7 +43,7 @@ fn main() {
cpu_id, cpu_id,
true, true,
parallel_mode, parallel_mode,
Some(parent_cpu_id.id.try_into().unwrap()), Some(parent_cpu_id.0.try_into().unwrap()),
) )
.unwrap(); .unwrap();
let observer = let observer =

View File

@ -2201,7 +2201,7 @@ where
while !self.is_shutting_down() { while !self.is_shutting_down() {
if current_milliseconds() > end_time { 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; end_time = current_milliseconds() + timeout;
} }

View File

@ -8,7 +8,6 @@ use core::{
option::Option, option::Option,
time::Duration, time::Duration,
}; };
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::fs; use std::fs;

View File

@ -73,7 +73,7 @@ where
"FixMe: Nyx InvalidWriteToPayload handler is missing", "FixMe: Nyx InvalidWriteToPayload handler is missing",
)), )),
NyxReturnValue::Error => Err(libafl::Error::illegal_state( NyxReturnValue::Error => Err(libafl::Error::illegal_state(
"Error: Nyx runtime error has occured...", "Error: Nyx runtime error has occurred...",
)), )),
NyxReturnValue::IoError => { NyxReturnValue::IoError => {
// todo! *stop_soon_p = 0 // todo! *stop_soon_p = 0

View File

@ -30,7 +30,7 @@ pub enum NyxProcessType {
CHILD, CHILD,
} }
impl NyxHelper { 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` /// 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 /// will fail if initial connection takes more than 2 seconds
pub fn new( pub fn new(
@ -49,7 +49,7 @@ impl NyxHelper {
INIT_TIMEOUT, 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` /// 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 /// will fail if initial connection takes more than `initial_timeout` seconds
pub fn with_initial_timeout( pub fn with_initial_timeout(
@ -110,7 +110,7 @@ impl NyxHelper {
match nyx_process.exec() { match nyx_process.exec() {
NyxReturnValue::Error => { NyxReturnValue::Error => {
nyx_process.shutdown(); 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)); return Err(Error::illegal_state(msg));
} }
NyxReturnValue::IoError => { NyxReturnValue::IoError => {
@ -119,7 +119,7 @@ impl NyxHelper {
} }
NyxReturnValue::Abort => { NyxReturnValue::Abort => {
nyx_process.shutdown(); nyx_process.shutdown();
let msg = "Error: Nyx abort occured..."; let msg = "Error: Nyx abort occurred...";
return Err(Error::illegal_state(msg)); 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) { pub fn set_timeout(mut self, time: Duration) {
let sec: u8 = time let sec: u8 = time
.as_secs() .as_secs()