Skip to content

Commit

Permalink
Merge branch 'main' into add-label-mutationresult
Browse files Browse the repository at this point in the history
  • Loading branch information
riesentoaster authored Dec 19, 2024
2 parents 6395df9 + e46cf8a commit 17c63fe
Show file tree
Hide file tree
Showing 11 changed files with 298 additions and 130 deletions.
2 changes: 1 addition & 1 deletion fuzzers/forkserver/forkserver_libafl_cc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use libafl::{
use libafl_bolts::{
rands::StdRand,
shmem::{ShMem, ShMemProvider, UnixShMemProvider},
tuples::{tuple_list, Handled, MatchNameRef, Merge},
tuples::{tuple_list, Handled, Merge},
AsSliceMut, Truncate,
};
use libafl_targets::EDGES_MAP_DEFAULT_SIZE;
Expand Down
11 changes: 4 additions & 7 deletions fuzzers/fuzz_anything/baby_no_std/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ extern crate alloc;
use alloc::ffi::CString;
#[cfg(not(any(windows)))]
use core::panic::PanicInfo;
use core::ptr::write;

use libafl::{
corpus::InMemoryCorpus,
Expand All @@ -20,12 +19,12 @@ use libafl::{
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::{havoc_mutations::havoc_mutations, scheduled::StdScheduledMutator},
observers::StdMapObserver,
observers::ConstMapObserver,
schedulers::QueueScheduler,
stages::mutational::StdMutationalStage,
state::StdState,
};
use libafl_bolts::{nonzero, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{nonnull_raw_mut, nonzero, rands::StdRand, tuples::tuple_list, AsSlice};
#[cfg(any(windows, unix))]
use libc::{abort, printf};
use static_alloc::Bump;
Expand All @@ -48,11 +47,10 @@ fn panic(_info: &PanicInfo) -> ! {

/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() };

/// Assign a signal to the signals map
fn signals_set(idx: usize) {
unsafe { write(SIGNALS_PTR.add(idx), 1) };
unsafe { SIGNALS[idx] = 1 };
}

/// Provide custom time in `no_std` environment
Expand Down Expand Up @@ -88,8 +86,7 @@ pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize {
};

// Create an observation channel using the signals map
let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) };

let observer = unsafe { ConstMapObserver::from_mut_ptr("signals", nonnull_raw_mut!(SIGNALS)) };
// Feedback to rate the interestingness of an input
let mut feedback = MaxMapFeedback::new(&observer);

Expand Down
2 changes: 1 addition & 1 deletion fuzzers/fuzz_anything/push_harness/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn input_generator() {
ExitKind::Ok
};

let signals_ptr = unsafe { &raw mut SIGNALS };
let signals_ptr = &raw mut SIGNALS;
let signals_len = unsafe { *signals_ptr }.len();

// Create an observation channel using the signals map
Expand Down
4 changes: 2 additions & 2 deletions fuzzers/inprocess/libfuzzer_libpng_accounting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! The example harness is built for libpng.
//! In this example, you will see the use of the `launcher` feature.
//! The `launcher` will spawn new processes for each cpu core.
use core::time::Duration;
use core::{ptr::addr_of, time::Duration};
use std::{env, net::SocketAddr, path::PathBuf};

use clap::Parser;
Expand Down Expand Up @@ -200,7 +200,7 @@ pub extern "C" fn libafl_main() {
&edges_observer,
&mut state,
QueueScheduler::new(),
unsafe { &ACCOUNTING_MEMOP_MAP },
unsafe { &*addr_of!(ACCOUNTING_MEMOP_MAP) },
);

// A fuzzer with feedbacks and a corpus scheduler
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/structure_aware/baby_fuzzer_gramatron/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use libafl_bolts::{rands::StdRand, tuples::tuple_list};
/// Coverage map with explicit assignments due to the lack of instrumentation
const SIGNALS_LEN: usize = 16;
static mut SIGNALS: [u8; SIGNALS_LEN] = [0; SIGNALS_LEN];
static mut SIGNALS_PTR: *mut u8 = unsafe { &raw mut SIGNALS as _ };
static mut SIGNALS_PTR: *mut u8 = &raw mut SIGNALS as _;
/*
/// Assign a signal to the signals map
fn signals_set(idx: usize) {
Expand Down
Loading

0 comments on commit 17c63fe

Please sign in to comment.