Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup clippy warnings in example fuzzers #2770

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 2 additions & 0 deletions fuzzers/fuzz_anything/baby_no_std/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fn panic(_info: &PanicInfo) -> ! {

/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
#[allow(static_mut_refs)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to not use static_mut_refs.
Ideally we should use this function instead to create the observer:

unsafe { ConstMapObserver::from_mut_ptr("signals", nonnull_raw_mut!(SIGNALS)) };

static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() };

/// Assign a signal to the signals map
Expand Down Expand Up @@ -88,6 +89,7 @@ pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize {
};

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

// Feedback to rate the interestingness of an input
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
3 changes: 2 additions & 1 deletion fuzzers/inprocess/libfuzzer_libpng_accounting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! The `launcher` will spawn new processes for each cpu core.
use core::time::Duration;
use std::{env, net::SocketAddr, path::PathBuf};
use core::ptr::addr_of;

use clap::Parser;
use libafl::{
Expand Down Expand Up @@ -200,7 +201,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