Clippy fixes for latest toolchain (#471)
* from warning * fix latest clippy * clippy fixes++ * more nits
This commit is contained in:
parent
aebd85f041
commit
2dd88998bd
@ -22,7 +22,7 @@ pub fn main() {
|
||||
.silence(true)
|
||||
// add arguments only if --libafl or --libafl-no-link are present
|
||||
.need_libafl_arg(true)
|
||||
.from_args(&args)
|
||||
.parse_args(&args)
|
||||
.expect("Failed to parse the command line")
|
||||
.link_staticlib(&dir, "fuzzbench")
|
||||
.add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp")
|
||||
|
@ -20,7 +20,7 @@ pub fn main() {
|
||||
.cpp(is_cpp)
|
||||
// silence the compiler wrapper output, needed for some configure scripts.
|
||||
.silence(true)
|
||||
.from_args(&args)
|
||||
.parse_args(&args)
|
||||
.expect("Failed to parse the command line")
|
||||
.link_staticlib(&dir, "generic_inmemory")
|
||||
.add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp")
|
||||
|
@ -20,7 +20,7 @@ pub fn main() {
|
||||
.cpp(is_cpp)
|
||||
// silence the compiler wrapper output, needed for some configure scripts.
|
||||
.silence(true)
|
||||
.from_args(&args)
|
||||
.parse_args(&args)
|
||||
.expect("Failed to parse the command line")
|
||||
.link_staticlib(&dir, "libfuzzer_libmozjpeg")
|
||||
.add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp")
|
||||
|
@ -20,7 +20,7 @@ pub fn main() {
|
||||
.cpp(is_cpp)
|
||||
// silence the compiler wrapper output, needed for some configure scripts.
|
||||
.silence(true)
|
||||
.from_args(&args)
|
||||
.parse_args(&args)
|
||||
.expect("Failed to parse the command line")
|
||||
.link_staticlib(&dir, "libfuzzer_libpng")
|
||||
.add_arg("-fsanitize-coverage=trace-pc-guard")
|
||||
|
@ -20,7 +20,7 @@ pub fn main() {
|
||||
.cpp(is_cpp)
|
||||
// silence the compiler wrapper output, needed for some configure scripts.
|
||||
.silence(true)
|
||||
.from_args(&args)
|
||||
.parse_args(&args)
|
||||
.expect("Failed to parse the command line")
|
||||
.add_pass(LLVMPasses::AFLCoverage)
|
||||
.add_arg("-mllvm")
|
||||
|
@ -20,7 +20,7 @@ pub fn main() {
|
||||
.cpp(is_cpp)
|
||||
// silence the compiler wrapper output, needed for some configure scripts.
|
||||
.silence(true)
|
||||
.from_args(&args)
|
||||
.parse_args(&args)
|
||||
.expect("Failed to parse the command line")
|
||||
.link_staticlib(&dir, "libfuzzer_libpng")
|
||||
.add_arg("-fsanitize-coverage=trace-pc-guard")
|
||||
|
@ -21,7 +21,7 @@ pub fn main() {
|
||||
.cpp(is_cpp)
|
||||
// silence the compiler wrapper output, needed for some configure scripts.
|
||||
.silence(true)
|
||||
.from_args(&args)
|
||||
.parse_args(&args)
|
||||
.expect("Failed to parse the command line")
|
||||
.add_link_arg(weak)
|
||||
.link_staticlib(&dir, "libfuzzer_libpng")
|
||||
|
@ -20,7 +20,7 @@ pub fn main() {
|
||||
.cpp(is_cpp)
|
||||
// silence the compiler wrapper output, needed for some configure scripts.
|
||||
.silence(true)
|
||||
.from_args(&args)
|
||||
.parse_args(&args)
|
||||
.expect("Failed to parse the command line")
|
||||
.link_staticlib(&dir, "tutorial")
|
||||
.add_arg("-fsanitize-coverage=trace-pc-guard")
|
||||
|
@ -1272,7 +1272,7 @@ where
|
||||
) -> Result<Self, Error> {
|
||||
Self::on_existing_map(
|
||||
shmem_provider.clone(),
|
||||
shmem_provider.from_description(description.shmem)?,
|
||||
shmem_provider.map_from_decription(description.shmem)?,
|
||||
description.last_message_offset,
|
||||
)
|
||||
}
|
||||
@ -1431,7 +1431,7 @@ where
|
||||
|
||||
// Map the new page. The old one should be unmapped by Drop
|
||||
self.current_recv_map =
|
||||
LlmpSharedMap::existing(self.shmem_provider.from_id_and_size(
|
||||
LlmpSharedMap::existing(self.shmem_provider.map_from_id_and_size(
|
||||
ShMemId::from_slice(&pageinfo_cpy.shm_str),
|
||||
pageinfo_cpy.map_size,
|
||||
)?);
|
||||
@ -1546,7 +1546,7 @@ where
|
||||
) -> Result<Self, Error> {
|
||||
Self::on_existing_map(
|
||||
shmem_provider.clone(),
|
||||
shmem_provider.from_description(description.shmem)?,
|
||||
shmem_provider.map_from_decription(description.shmem)?,
|
||||
description.last_message_offset,
|
||||
)
|
||||
}
|
||||
@ -1855,7 +1855,7 @@ where
|
||||
)?;
|
||||
|
||||
let new_map =
|
||||
LlmpSharedMap::existing(self.shmem_provider.from_description(map_description)?);
|
||||
LlmpSharedMap::existing(self.shmem_provider.map_from_decription(map_description)?);
|
||||
|
||||
{
|
||||
self.register_client(new_map);
|
||||
@ -2207,7 +2207,7 @@ where
|
||||
last_msg_sent: ptr::null_mut(),
|
||||
out_maps: vec![LlmpSharedMap::existing(
|
||||
shmem_provider_bg
|
||||
.from_description(tcp_out_map_description)
|
||||
.map_from_decription(tcp_out_map_description)
|
||||
.unwrap(),
|
||||
)],
|
||||
// drop pages to the broker, if it already read them.
|
||||
@ -2313,7 +2313,7 @@ where
|
||||
} else {
|
||||
let pageinfo = (*msg).buf.as_mut_ptr() as *mut LlmpPayloadSharedMapInfo;
|
||||
|
||||
match self.shmem_provider.from_id_and_size(
|
||||
match self.shmem_provider.map_from_id_and_size(
|
||||
ShMemId::from_slice(&(*pageinfo).shm_str),
|
||||
(*pageinfo).map_size,
|
||||
) {
|
||||
@ -2638,7 +2638,8 @@ where
|
||||
));
|
||||
};
|
||||
|
||||
let map = LlmpSharedMap::existing(shmem_provider.from_description(broker_map_description)?);
|
||||
let map =
|
||||
LlmpSharedMap::existing(shmem_provider.map_from_decription(broker_map_description)?);
|
||||
let mut ret = Self::new(shmem_provider, map)?;
|
||||
|
||||
let client_hello_req = TcpRequest::LocalClientHello {
|
||||
|
@ -9,7 +9,7 @@ use crate::{
|
||||
bolts::shmem::{ShMem, ShMemDescription, ShMemId, ShMemProvider},
|
||||
Error,
|
||||
};
|
||||
use core::mem::ManuallyDrop;
|
||||
use core::{mem::ManuallyDrop, ptr::addr_of};
|
||||
use hashbrown::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
@ -177,14 +177,16 @@ where
|
||||
|
||||
Ok(ServedShMem {
|
||||
inner: ManuallyDrop::new(
|
||||
self.inner
|
||||
.from_id_and_size(ShMemId::from_string(&format!("{}", client_fd)), map_size)?,
|
||||
self.inner.map_from_id_and_size(
|
||||
ShMemId::from_string(&format!("{}", client_fd)),
|
||||
map_size,
|
||||
)?,
|
||||
),
|
||||
server_fd,
|
||||
})
|
||||
}
|
||||
|
||||
fn from_id_and_size(&mut self, id: ShMemId, size: usize) -> Result<Self::Mem, Error> {
|
||||
fn map_from_id_and_size(&mut self, id: ShMemId, size: usize) -> Result<Self::Mem, Error> {
|
||||
let parts = id.as_str().split(':').collect::<Vec<&str>>();
|
||||
let server_id_str = parts.get(0).unwrap();
|
||||
let (server_fd, client_fd) = self.send_receive(ServedShMemRequest::ExistingMap(
|
||||
@ -193,7 +195,7 @@ where
|
||||
Ok(ServedShMem {
|
||||
inner: ManuallyDrop::new(
|
||||
self.inner
|
||||
.from_id_and_size(ShMemId::from_string(&format!("{}", client_fd)), size)?,
|
||||
.map_from_id_and_size(ShMemId::from_string(&format!("{}", client_fd)), size)?,
|
||||
),
|
||||
server_fd,
|
||||
})
|
||||
@ -649,8 +651,7 @@ where
|
||||
let copied_poll_fds: Vec<PollFd> = poll_fds.clone();
|
||||
for poll_fd in copied_poll_fds {
|
||||
let revents = poll_fd.revents().expect("revents should not be None");
|
||||
let raw_polled_fd =
|
||||
unsafe { *((&poll_fd as *const PollFd) as *const libc::pollfd) }.fd;
|
||||
let raw_polled_fd = unsafe { *((addr_of!(poll_fd)) as *const libc::pollfd) }.fd;
|
||||
if revents.contains(PollFlags::POLLHUP) {
|
||||
poll_fds.remove(poll_fds.iter().position(|item| *item == poll_fd).unwrap());
|
||||
self.clients.remove(&raw_polled_fd);
|
||||
|
@ -4,7 +4,7 @@ use core::{
|
||||
cell::UnsafeCell,
|
||||
fmt::{self, Display, Formatter},
|
||||
mem, ptr,
|
||||
ptr::write_volatile,
|
||||
ptr::{addr_of_mut, write_volatile},
|
||||
sync::atomic::{compiler_fence, Ordering},
|
||||
};
|
||||
|
||||
@ -214,11 +214,11 @@ pub unsafe fn setup_signal_handler<T: 'static + Handler>(handler: &mut T) -> Res
|
||||
let mut ss: stack_t = mem::zeroed();
|
||||
ss.ss_size = SIGNAL_STACK_SIZE;
|
||||
ss.ss_sp = SIGNAL_STACK_PTR;
|
||||
sigaltstack(&mut ss as *mut stack_t, ptr::null_mut() as _);
|
||||
sigaltstack(addr_of_mut!(ss), ptr::null_mut() as _);
|
||||
|
||||
let mut sa: sigaction = mem::zeroed();
|
||||
sigemptyset(&mut sa.sa_mask as *mut libc::sigset_t);
|
||||
sigaddset(&mut sa.sa_mask as *mut libc::sigset_t, SIGALRM);
|
||||
sigemptyset(addr_of_mut!(sa.sa_mask));
|
||||
sigaddset(addr_of_mut!(sa.sa_mask), SIGALRM);
|
||||
sa.sa_flags = SA_NODEFER | SA_SIGINFO | SA_ONSTACK;
|
||||
sa.sa_sigaction = handle_signal as usize;
|
||||
let signals = handler.signals();
|
||||
@ -230,7 +230,7 @@ pub unsafe fn setup_signal_handler<T: 'static + Handler>(handler: &mut T) -> Res
|
||||
}),
|
||||
);
|
||||
|
||||
if sigaction(sig as i32, &mut sa as *mut sigaction, ptr::null_mut()) < 0 {
|
||||
if sigaction(sig as i32, addr_of_mut!(sa), ptr::null_mut()) < 0 {
|
||||
#[cfg(feature = "std")]
|
||||
{
|
||||
let err_str = CString::new(format!("Failed to setup {} handler", sig)).unwrap();
|
||||
|
@ -6,6 +6,7 @@ use alloc::boxed::Box;
|
||||
use core::{
|
||||
any::{Any, TypeId},
|
||||
fmt::Debug,
|
||||
ptr::addr_of,
|
||||
};
|
||||
|
||||
// yolo
|
||||
@ -18,7 +19,7 @@ use core::{
|
||||
#[must_use]
|
||||
pub fn pack_type_id(id: u64) -> TypeId {
|
||||
assert_eq_size!(TypeId, u64);
|
||||
unsafe { *(&id as *const u64 as *const TypeId) }
|
||||
unsafe { *(addr_of!(id) as *const TypeId) }
|
||||
}
|
||||
|
||||
/// Unpack a `type_id` to an `u64`
|
||||
@ -29,7 +30,7 @@ pub fn pack_type_id(id: u64) -> TypeId {
|
||||
#[must_use]
|
||||
pub fn unpack_type_id(id: TypeId) -> u64 {
|
||||
assert_eq_size!(TypeId, u64);
|
||||
unsafe { *(&id as *const _ as *const u64) }
|
||||
unsafe { *(addr_of!(id) as *const u64) }
|
||||
}
|
||||
|
||||
/// A (de)serializable Any trait
|
||||
|
@ -215,16 +215,16 @@ pub trait ShMemProvider: Clone + Default + Debug {
|
||||
fn new_map(&mut self, map_size: usize) -> Result<Self::Mem, Error>;
|
||||
|
||||
/// Get a mapping given its id and size
|
||||
fn from_id_and_size(&mut self, id: ShMemId, size: usize) -> Result<Self::Mem, Error>;
|
||||
fn map_from_id_and_size(&mut self, id: ShMemId, size: usize) -> Result<Self::Mem, Error>;
|
||||
|
||||
/// Get a mapping given a description
|
||||
fn from_description(&mut self, description: ShMemDescription) -> Result<Self::Mem, Error> {
|
||||
self.from_id_and_size(description.id, description.size)
|
||||
fn map_from_decription(&mut self, description: ShMemDescription) -> Result<Self::Mem, Error> {
|
||||
self.map_from_id_and_size(description.id, description.size)
|
||||
}
|
||||
|
||||
/// Create a new sharedmap reference from an existing `id` and `len`
|
||||
fn clone_ref(&mut self, mapping: &Self::Mem) -> Result<Self::Mem, Error> {
|
||||
self.from_id_and_size(mapping.id(), mapping.len())
|
||||
self.map_from_id_and_size(mapping.id(), mapping.len())
|
||||
}
|
||||
|
||||
/// Reads an existing map config from env vars, then maps it
|
||||
@ -232,7 +232,7 @@ pub trait ShMemProvider: Clone + Default + Debug {
|
||||
fn existing_from_env(&mut self, env_name: &str) -> Result<Self::Mem, Error> {
|
||||
let map_shm_str = env::var(env_name)?;
|
||||
let map_size = str::parse::<usize>(&env::var(format!("{}_SIZE", env_name))?)?;
|
||||
self.from_description(ShMemDescription::from_string_and_size(
|
||||
self.map_from_decription(ShMemDescription::from_string_and_size(
|
||||
&map_shm_str,
|
||||
map_size,
|
||||
))
|
||||
@ -342,9 +342,9 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
fn from_id_and_size(&mut self, id: ShMemId, size: usize) -> Result<Self::Mem, Error> {
|
||||
fn map_from_id_and_size(&mut self, id: ShMemId, size: usize) -> Result<Self::Mem, Error> {
|
||||
Ok(Self::Mem {
|
||||
internal: ManuallyDrop::new(self.internal.borrow_mut().from_id_and_size(id, size)?),
|
||||
internal: ManuallyDrop::new(self.internal.borrow_mut().map_from_id_and_size(id, size)?),
|
||||
provider: self.internal.clone(),
|
||||
})
|
||||
}
|
||||
@ -622,7 +622,7 @@ pub mod unix_shmem {
|
||||
}
|
||||
}
|
||||
|
||||
fn from_id_and_size(id: ShMemId, map_size: usize) -> Result<Self, Error> {
|
||||
fn map_from_id_and_size(id: ShMemId, map_size: usize) -> Result<Self, Error> {
|
||||
unsafe {
|
||||
let shm_fd: i32 = id.to_string().parse().unwrap();
|
||||
|
||||
@ -684,8 +684,12 @@ pub mod unix_shmem {
|
||||
MmapShMem::new(map_size, self.current_map_id)
|
||||
}
|
||||
|
||||
fn from_id_and_size(&mut self, id: ShMemId, size: usize) -> Result<Self::Mem, Error> {
|
||||
MmapShMem::from_id_and_size(id, size)
|
||||
fn map_from_id_and_size(
|
||||
&mut self,
|
||||
id: ShMemId,
|
||||
size: usize,
|
||||
) -> Result<Self::Mem, Error> {
|
||||
MmapShMem::map_from_id_and_size(id, size)
|
||||
}
|
||||
}
|
||||
|
||||
@ -771,7 +775,7 @@ pub mod unix_shmem {
|
||||
}
|
||||
|
||||
/// Get a [`UnixShMem`] of the existing shared memory mapping identified by id
|
||||
pub fn from_id_and_size(id: ShMemId, map_size: usize) -> Result<Self, Error> {
|
||||
pub fn map_from_id_and_size(id: ShMemId, map_size: usize) -> Result<Self, Error> {
|
||||
unsafe {
|
||||
let id_int: i32 = id.into();
|
||||
let map = shmat(id_int, ptr::null(), 0) as *mut c_uchar;
|
||||
@ -843,8 +847,12 @@ pub mod unix_shmem {
|
||||
CommonUnixShMem::new(map_size)
|
||||
}
|
||||
|
||||
fn from_id_and_size(&mut self, id: ShMemId, size: usize) -> Result<Self::Mem, Error> {
|
||||
CommonUnixShMem::from_id_and_size(id, size)
|
||||
fn map_from_id_and_size(
|
||||
&mut self,
|
||||
id: ShMemId,
|
||||
size: usize,
|
||||
) -> Result<Self::Mem, Error> {
|
||||
CommonUnixShMem::map_from_id_and_size(id, size)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -951,7 +959,7 @@ pub mod unix_shmem {
|
||||
}
|
||||
|
||||
/// Get a [`crate::bolts::shmem::unix_shmem::UnixShMem`] of the existing [`ShMem`] mapping identified by id.
|
||||
pub fn from_id_and_size(id: ShMemId, map_size: usize) -> Result<Self, Error> {
|
||||
pub fn map_from_id_and_size(id: ShMemId, map_size: usize) -> Result<Self, Error> {
|
||||
unsafe {
|
||||
let fd: i32 = id.to_string().parse().unwrap();
|
||||
#[allow(trivial_numeric_casts, clippy::cast_sign_loss)]
|
||||
@ -1055,8 +1063,12 @@ pub mod unix_shmem {
|
||||
Ok(mapping)
|
||||
}
|
||||
|
||||
fn from_id_and_size(&mut self, id: ShMemId, size: usize) -> Result<Self::Mem, Error> {
|
||||
AshmemShMem::from_id_and_size(id, size)
|
||||
fn map_from_id_and_size(
|
||||
&mut self,
|
||||
id: ShMemId,
|
||||
size: usize,
|
||||
) -> Result<Self::Mem, Error> {
|
||||
AshmemShMem::map_from_id_and_size(id, size)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1147,7 +1159,7 @@ pub mod win32_shmem {
|
||||
}
|
||||
}
|
||||
|
||||
fn from_id_and_size(id: ShMemId, map_size: usize) -> Result<Self, Error> {
|
||||
fn map_from_id_and_size(id: ShMemId, map_size: usize) -> Result<Self, Error> {
|
||||
unsafe {
|
||||
let map_str_bytes = id.id;
|
||||
// Unlike MapViewOfFile this one needs u32
|
||||
@ -1228,8 +1240,8 @@ pub mod win32_shmem {
|
||||
Win32ShMem::new_map(map_size)
|
||||
}
|
||||
|
||||
fn from_id_and_size(&mut self, id: ShMemId, size: usize) -> Result<Self::Mem, Error> {
|
||||
Win32ShMem::from_id_and_size(id, size)
|
||||
fn map_from_id_and_size(&mut self, id: ShMemId, size: usize) -> Result<Self::Mem, Error> {
|
||||
Win32ShMem::map_from_id_and_size(id, size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,10 @@
|
||||
|
||||
pub use tuple_list::{tuple_list, tuple_list_type, TupleList};
|
||||
|
||||
use core::any::TypeId;
|
||||
use core::{
|
||||
any::TypeId,
|
||||
ptr::{addr_of, addr_of_mut},
|
||||
};
|
||||
|
||||
use xxhash_rust::xxh3::xxh3_64;
|
||||
|
||||
@ -142,7 +145,7 @@ where
|
||||
{
|
||||
fn match_first_type<T: 'static>(&self) -> Option<&T> {
|
||||
if TypeId::of::<T>() == TypeId::of::<Head>() {
|
||||
unsafe { (&self.0 as *const _ as *const T).as_ref() }
|
||||
unsafe { (addr_of!(self.0) as *const T).as_ref() }
|
||||
} else {
|
||||
self.1.match_first_type::<T>()
|
||||
}
|
||||
@ -150,7 +153,7 @@ where
|
||||
|
||||
fn match_first_type_mut<T: 'static>(&mut self) -> Option<&mut T> {
|
||||
if TypeId::of::<T>() == TypeId::of::<Head>() {
|
||||
unsafe { (&mut self.0 as *mut _ as *mut T).as_mut() }
|
||||
unsafe { (addr_of_mut!(self.0) as *mut T).as_mut() }
|
||||
} else {
|
||||
self.1.match_first_type_mut::<T>()
|
||||
}
|
||||
@ -178,7 +181,7 @@ where
|
||||
fn match_type<T: 'static>(&self, f: fn(t: &T)) {
|
||||
// Switch this check to https://stackoverflow.com/a/60138532/7658998 when in stable and remove 'static
|
||||
if TypeId::of::<T>() == TypeId::of::<Head>() {
|
||||
f(unsafe { (&self.0 as *const _ as *const T).as_ref() }.unwrap());
|
||||
f(unsafe { (addr_of!(self.0) as *const T).as_ref() }.unwrap());
|
||||
}
|
||||
self.1.match_type::<T>(f);
|
||||
}
|
||||
@ -186,7 +189,7 @@ where
|
||||
fn match_type_mut<T: 'static>(&mut self, f: fn(t: &mut T)) {
|
||||
// Switch this check to https://stackoverflow.com/a/60138532/7658998 when in stable and remove 'static
|
||||
if TypeId::of::<T>() == TypeId::of::<Head>() {
|
||||
f(unsafe { (&mut self.0 as *mut _ as *mut T).as_mut() }.unwrap());
|
||||
f(unsafe { (addr_of_mut!(self.0) as *mut T).as_mut() }.unwrap());
|
||||
}
|
||||
self.1.match_type_mut::<T>(f);
|
||||
}
|
||||
@ -251,7 +254,7 @@ where
|
||||
{
|
||||
fn match_name<T>(&self, name: &str) -> Option<&T> {
|
||||
if type_eq::<Head, T>() && name == self.0.name() {
|
||||
unsafe { (&self.0 as *const _ as *const T).as_ref() }
|
||||
unsafe { (addr_of!(self.0) as *const T).as_ref() }
|
||||
} else {
|
||||
self.1.match_name::<T>(name)
|
||||
}
|
||||
@ -259,7 +262,7 @@ where
|
||||
|
||||
fn match_name_mut<T>(&mut self, name: &str) -> Option<&mut T> {
|
||||
if type_eq::<Head, T>() && name == self.0.name() {
|
||||
unsafe { (&mut self.0 as *mut _ as *mut T).as_mut() }
|
||||
unsafe { (addr_of_mut!(self.0) as *mut T).as_mut() }
|
||||
} else {
|
||||
self.1.match_name_mut::<T>(name)
|
||||
}
|
||||
@ -291,7 +294,7 @@ where
|
||||
fn match_name_type<T: 'static>(&self, name: &str) -> Option<&T> {
|
||||
// Switch this check to https://stackoverflow.com/a/60138532/7658998 when in stable and remove 'static
|
||||
if TypeId::of::<T>() == TypeId::of::<Head>() && name == self.0.name() {
|
||||
unsafe { (&self.0 as *const _ as *const T).as_ref() }
|
||||
unsafe { (addr_of!(self.0) as *const T).as_ref() }
|
||||
} else {
|
||||
self.1.match_name_type::<T>(name)
|
||||
}
|
||||
@ -300,7 +303,7 @@ where
|
||||
fn match_name_type_mut<T: 'static>(&mut self, name: &str) -> Option<&mut T> {
|
||||
// Switch this check to https://stackoverflow.com/a/60138532/7658998 when in stable and remove 'static
|
||||
if TypeId::of::<T>() == TypeId::of::<Head>() && name == self.0.name() {
|
||||
unsafe { (&mut self.0 as *mut _ as *mut T).as_mut() }
|
||||
unsafe { (addr_of_mut!(self.0) as *mut T).as_mut() }
|
||||
} else {
|
||||
self.1.match_name_type_mut::<T>(name)
|
||||
}
|
||||
|
@ -868,9 +868,9 @@ where
|
||||
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
|
||||
#[allow(clippy::manual_assert)]
|
||||
if !staterestorer.has_content() {
|
||||
#[cfg(unix)]
|
||||
#[allow(clippy::manual_assert)]
|
||||
if child_status == 137 {
|
||||
// Out of Memory, see https://tldp.org/LDP/abs/html/exitcodes.html
|
||||
// and https://github.com/AFLplusplus/LibAFL/issues/32 for discussion.
|
||||
|
@ -366,9 +366,9 @@ where
|
||||
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
|
||||
#[allow(clippy::manual_assert)]
|
||||
if !staterestorer.has_content() {
|
||||
#[cfg(unix)]
|
||||
#[allow(clippy::manual_assert)]
|
||||
if child_status == 137 {
|
||||
// Out of Memory, see https://tldp.org/LDP/abs/html/exitcodes.html
|
||||
// and https://github.com/AFLplusplus/LibAFL/issues/32 for discussion.
|
||||
|
@ -95,7 +95,6 @@ use crate::monitors::PerfFeature;
|
||||
#[cfg(feature = "concolic_mutation")]
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn generate_mutations(iter: impl Iterator<Item = (SymExprRef, SymExpr)>) -> Vec<Vec<(usize, u8)>> {
|
||||
use core::mem::size_of;
|
||||
use hashbrown::HashMap;
|
||||
use z3::{
|
||||
ast::{Ast, Bool, Dynamic, BV},
|
||||
@ -168,9 +167,7 @@ fn generate_mutations(iter: impl Iterator<Item = (SymExprRef, SymExpr)>) -> Vec<
|
||||
Some(BV::from_u64(&ctx, value, u32::from(bits)).into())
|
||||
}
|
||||
SymExpr::Integer128 { high: _, low: _ } => todo!(),
|
||||
SymExpr::NullPointer => {
|
||||
Some(BV::from_u64(&ctx, 0, (8 * size_of::<usize>()) as u32).into())
|
||||
}
|
||||
SymExpr::NullPointer => Some(BV::from_u64(&ctx, 0, usize::BITS).into()),
|
||||
SymExpr::True => Some(Bool::from_bool(&ctx, true).into()),
|
||||
SymExpr::False => Some(Bool::from_bool(&ctx, false).into()),
|
||||
SymExpr::Bool { value } => Some(Bool::from_bool(&ctx, value).into()),
|
||||
|
@ -63,7 +63,7 @@ pub struct ClangWrapper {
|
||||
need_libafl_arg: bool,
|
||||
has_libafl_arg: bool,
|
||||
|
||||
from_args_called: bool,
|
||||
parse_args_called: bool,
|
||||
base_args: Vec<String>,
|
||||
cc_args: Vec<String>,
|
||||
link_args: Vec<String>,
|
||||
@ -72,7 +72,7 @@ pub struct ClangWrapper {
|
||||
|
||||
#[allow(clippy::match_same_arms)] // for the linking = false wip for "shared"
|
||||
impl CompilerWrapper for ClangWrapper {
|
||||
fn from_args<S>(&mut self, args: &[S]) -> Result<&'_ mut Self, Error>
|
||||
fn parse_args<S>(&mut self, args: &[S]) -> Result<&'_ mut Self, Error>
|
||||
where
|
||||
S: AsRef<str>,
|
||||
{
|
||||
@ -83,13 +83,13 @@ impl CompilerWrapper for ClangWrapper {
|
||||
));
|
||||
}
|
||||
|
||||
if self.from_args_called {
|
||||
if self.parse_args_called {
|
||||
return Err(Error::Unknown(
|
||||
"CompilerWrapper::from_args cannot be called twice on the same instance"
|
||||
"CompilerWrapper::parse_args cannot be called twice on the same instance"
|
||||
.to_string(),
|
||||
));
|
||||
}
|
||||
self.from_args_called = true;
|
||||
self.parse_args_called = true;
|
||||
|
||||
if args.len() == 1 {
|
||||
return Err(Error::InvalidArguments(
|
||||
@ -283,7 +283,7 @@ impl ClangWrapper {
|
||||
bit_mode: 0,
|
||||
need_libafl_arg: false,
|
||||
has_libafl_arg: false,
|
||||
from_args_called: false,
|
||||
parse_args_called: false,
|
||||
base_args: vec![],
|
||||
cc_args: vec![],
|
||||
link_args: vec![],
|
||||
@ -342,7 +342,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_clang_version() {
|
||||
if let Err(res) = ClangWrapper::new()
|
||||
.from_args(&["my-clang", "-v"])
|
||||
.parse_args(&["my-clang", "-v"])
|
||||
.unwrap()
|
||||
.run()
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ pub const LIB_PREFIX: &str = "lib";
|
||||
/// Wrap a compiler hijacking its arguments
|
||||
pub trait CompilerWrapper {
|
||||
/// Set the wrapper arguments parsing a command line set of arguments
|
||||
fn from_args<S>(&mut self, args: &[S]) -> Result<&'_ mut Self, Error>
|
||||
fn parse_args<S>(&mut self, args: &[S]) -> Result<&'_ mut Self, Error>
|
||||
where
|
||||
S: AsRef<str>;
|
||||
|
||||
|
@ -7,7 +7,10 @@ this helps finding mem errors early.
|
||||
*/
|
||||
|
||||
use backtrace::Backtrace;
|
||||
use core::fmt::{self, Debug, Formatter};
|
||||
use core::{
|
||||
fmt::{self, Debug, Formatter},
|
||||
ptr::addr_of_mut,
|
||||
};
|
||||
use frida_gum::{ModuleDetails, NativePointer, RangeDetails};
|
||||
use hashbrown::HashMap;
|
||||
use nix::sys::mman::{mmap, MapFlags, ProtFlags};
|
||||
@ -362,7 +365,7 @@ impl AsanRuntime {
|
||||
rlim_cur: 0,
|
||||
rlim_max: 0,
|
||||
};
|
||||
assert!(unsafe { getrlimit(RLIMIT_STACK, &mut stack_rlimit as *mut rlimit) } == 0);
|
||||
assert!(unsafe { getrlimit(RLIMIT_STACK, addr_of_mut!(stack_rlimit)) } == 0);
|
||||
|
||||
stack_rlimit.rlim_cur as usize
|
||||
}
|
||||
@ -387,7 +390,7 @@ impl AsanRuntime {
|
||||
#[must_use]
|
||||
pub fn current_stack() -> (usize, usize) {
|
||||
let mut stack_var = 0xeadbeef;
|
||||
let stack_address = &mut stack_var as *mut _ as *mut c_void as usize;
|
||||
let stack_address = addr_of_mut!(stack_var) as usize;
|
||||
let range_details = RangeDetails::with_address(stack_address as u64).unwrap();
|
||||
// Write something to (hopefully) make sure the val isn't optimized out
|
||||
unsafe {
|
||||
@ -1853,7 +1856,7 @@ impl AsanRuntime {
|
||||
; self_addr:
|
||||
; .qword self as *mut _ as *mut c_void as i64
|
||||
; self_regs_addr:
|
||||
; .qword &mut self.regs as *mut _ as *mut c_void as i64
|
||||
; .qword addr_of_mut!(self.regs) as i64
|
||||
; trap_func:
|
||||
; .qword AsanRuntime::handle_trap as *mut c_void as i64
|
||||
);
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Functionality regarding binary-only coverage collection.
|
||||
use core::ptr::addr_of_mut;
|
||||
use dynasmrt::{dynasm, DynasmApi, DynasmLabelApi};
|
||||
use std::ffi::c_void;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use frida_gum::instruction_writer::X86Register;
|
||||
@ -116,7 +116,7 @@ impl CoverageRuntime {
|
||||
; popfq
|
||||
; ret
|
||||
;map_addr:
|
||||
;.qword &mut self.map as *mut _ as *mut c_void as i64
|
||||
;.qword addr_of_mut!(self.map) as i64
|
||||
;previous_loc:
|
||||
;.qword 0
|
||||
);
|
||||
@ -152,7 +152,7 @@ impl CoverageRuntime {
|
||||
|
||||
self.current_log_impl = writer.pc();
|
||||
writer.put_bytes(self.blob_maybe_log());
|
||||
let prev_loc_pointer = &mut self.previous_pc as *mut _ as u64; // Get the pointer to self.previous_pc
|
||||
let prev_loc_pointer = addr_of_mut!(self.previous_pc) as u64; // Get the pointer to self.previous_pc
|
||||
|
||||
writer.put_bytes(&prev_loc_pointer.to_ne_bytes());
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
//! writing basic-block trace files to be read by coverage analysis tools, such as [Lighthouse](https://github.com/gaasedelen/lighthouse),
|
||||
//! [bncov](https://github.com/ForAllSecure/bncov), [dragondance](https://github.com/0ffffffffh/dragondance), etc.
|
||||
|
||||
use core::ptr::addr_of;
|
||||
use libafl::Error;
|
||||
use rangemap::RangeMap;
|
||||
use std::{
|
||||
@ -97,7 +98,7 @@ impl<'a> DrCovWriter<'a> {
|
||||
};
|
||||
writer
|
||||
.write_all(unsafe {
|
||||
std::slice::from_raw_parts(&basic_block as *const _ as *const u8, 8)
|
||||
std::slice::from_raw_parts(addr_of!(basic_block) as *const u8, 8)
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ pub fn libfuzzer_initialize(args: &[String]) -> i32 {
|
||||
#[allow(clippy::cast_possible_wrap)]
|
||||
let argc = argv.len() as i32;
|
||||
unsafe {
|
||||
libafl_targets_libfuzzer_init(
|
||||
&argc as *const i32,
|
||||
&argv.as_ptr() as *const *const *const u8,
|
||||
)
|
||||
let argv_ptr = argv.as_ptr();
|
||||
libafl_targets_libfuzzer_init(core::ptr::addr_of!(argc), core::ptr::addr_of!(argv_ptr))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user