ix UB in baby_fuzzer_grimoire (#1166)

This commit is contained in:
v1ce0ye 2023-03-22 22:37:57 +08:00 committed by GitHub
parent 38ea17b426
commit 7c514c3669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
#[cfg(windows)]
use std::ptr::write_volatile;
use std::{fs, io::Read, path::PathBuf};
use std::{fs, io::Read, path::PathBuf,ptr::write};
use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
@ -24,10 +24,10 @@ use libafl::{
/// 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 { SIGNALS[idx] = 1 };
unsafe{write(SIGNALS_PTR.add(idx),1)};
}
fn is_sub<T: PartialEq>(mut haystack: &[T], needle: &[T]) -> bool {
@ -82,8 +82,7 @@ pub fn main() {
};
// Create an observation channel using the signals map
let observer = unsafe { StdMapObserver::new("signals", &mut SIGNALS) };
let observer=unsafe{StdMapObserver::from_mut_ptr("signals",SIGNALS_PTR,SIGNALS.len())};
// Feedback to rate the interestingness of an input
let mut feedback = MaxMapFeedback::tracking(&observer, false, true);