Cleanup Pointer Clippy Lints (#1861)
* Fix pointer clippy lints * More clippy * fix build * fix
This commit is contained in:
parent
b999b4aac5
commit
0a995f241c
@ -368,17 +368,13 @@ pub mod pybind {
|
||||
|
||||
#[inline]
|
||||
fn current(&self) -> &Option<CorpusId> {
|
||||
let ptr = unwrap_me!(self.wrapper, c, {
|
||||
core::ptr::from_ref::<Option<CorpusId>>(c.current())
|
||||
});
|
||||
let ptr = unwrap_me!(self.wrapper, c, { core::ptr::from_ref(c.current()) });
|
||||
unsafe { ptr.as_ref().unwrap() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn current_mut(&mut self) -> &mut Option<CorpusId> {
|
||||
let ptr = unwrap_me_mut!(self.wrapper, c, {
|
||||
core::ptr::from_mut::<Option<CorpusId>>(c.current_mut())
|
||||
});
|
||||
let ptr = unwrap_me_mut!(self.wrapper, c, { core::ptr::from_mut(c.current_mut()) });
|
||||
unsafe { ptr.as_mut().unwrap() }
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//! It wraps two executors that will be run after each other with the same input.
|
||||
//! In comparison to the [`crate::executors::CombinedExecutor`] it also runs the secondary executor in `run_target`.
|
||||
//!
|
||||
use core::{cell::UnsafeCell, fmt::Debug};
|
||||
use core::{cell::UnsafeCell, fmt::Debug, ptr};
|
||||
|
||||
use libafl_bolts::{ownedref::OwnedMutPtr, tuples::MatchName};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -205,8 +205,8 @@ where
|
||||
|
||||
impl<A, B, DOT> ProxyObserversTuple<A, B, DOT> {
|
||||
fn set(&mut self, primary: &A, secondary: &B) {
|
||||
self.primary = OwnedMutPtr::Ptr(core::ptr::from_ref::<A>(primary) as *mut A);
|
||||
self.secondary = OwnedMutPtr::Ptr(core::ptr::from_ref::<B>(secondary) as *mut B);
|
||||
self.primary = OwnedMutPtr::Ptr(ptr::from_ref(primary) as *mut A);
|
||||
self.secondary = OwnedMutPtr::Ptr(ptr::from_ref(secondary) as *mut B);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ use core::{
|
||||
#[cfg(target_os = "linux")]
|
||||
use core::{
|
||||
mem::zeroed,
|
||||
ptr::{addr_of, null_mut},
|
||||
ptr::{self, addr_of, null_mut},
|
||||
};
|
||||
|
||||
#[cfg(all(unix, not(target_os = "linux")))]
|
||||
@ -299,7 +299,7 @@ impl TimerStruct {
|
||||
let data = addr_of_mut!(GLOBAL_STATE);
|
||||
write_volatile(
|
||||
addr_of_mut!((*data).executor_ptr),
|
||||
core::ptr::from_mut(self) as *mut c_void,
|
||||
ptr::from_mut(self) as *mut c_void,
|
||||
);
|
||||
|
||||
if self.executions == 0 {
|
||||
|
@ -185,8 +185,8 @@ pub mod unix_signal_handler {
|
||||
{
|
||||
#[cfg(all(target_os = "android", target_arch = "aarch64"))]
|
||||
let _context = _context.map(|p| {
|
||||
&mut *(((p as *mut _ as *mut libc::c_void as usize) + 128) as *mut libc::c_void
|
||||
as *mut ucontext_t)
|
||||
&mut *(((core::ptr::from_mut(p) as *mut libc::c_void as usize) + 128)
|
||||
as *mut libc::c_void as *mut ucontext_t)
|
||||
});
|
||||
|
||||
log::error!("Crashed with {signal}");
|
||||
|
@ -10,7 +10,7 @@ use core::{
|
||||
ffi::c_void,
|
||||
fmt::{self, Debug, Formatter},
|
||||
marker::PhantomData,
|
||||
ptr::{addr_of_mut, null, write_volatile},
|
||||
ptr::{self, addr_of_mut, null, write_volatile},
|
||||
sync::atomic::{compiler_fence, Ordering},
|
||||
time::Duration,
|
||||
};
|
||||
@ -178,25 +178,25 @@ where
|
||||
let data = addr_of_mut!(GLOBAL_STATE);
|
||||
write_volatile(
|
||||
addr_of_mut!((*data).current_input_ptr),
|
||||
core::ptr::from_ref(input) as *const c_void,
|
||||
ptr::from_ref(input) as *const c_void,
|
||||
);
|
||||
write_volatile(
|
||||
addr_of_mut!((*data).executor_ptr),
|
||||
core::ptr::from_ref(self) as *const c_void,
|
||||
ptr::from_ref(self) as *const c_void,
|
||||
);
|
||||
// Direct raw pointers access /aliasing is pretty undefined behavior.
|
||||
// Since the state and event may have moved in memory, refresh them right before the signal may happen
|
||||
write_volatile(
|
||||
addr_of_mut!((*data).state_ptr),
|
||||
core::ptr::from_mut(state) as *mut c_void,
|
||||
ptr::from_mut(state) as *mut c_void,
|
||||
);
|
||||
write_volatile(
|
||||
addr_of_mut!((*data).event_mgr_ptr),
|
||||
core::ptr::from_mut(mgr) as *mut c_void,
|
||||
ptr::from_mut(mgr) as *mut c_void,
|
||||
);
|
||||
write_volatile(
|
||||
addr_of_mut!((*data).fuzzer_ptr),
|
||||
core::ptr::from_mut(fuzzer) as *mut c_void,
|
||||
ptr::from_mut(fuzzer) as *mut c_void,
|
||||
);
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use core::{
|
||||
ffi::c_void,
|
||||
fmt::{self, Debug, Formatter},
|
||||
marker::PhantomData,
|
||||
ptr::{addr_of_mut, null_mut, write_volatile},
|
||||
ptr::{self, addr_of_mut, null_mut, write_volatile},
|
||||
sync::atomic::{compiler_fence, Ordering},
|
||||
time::Duration,
|
||||
};
|
||||
@ -278,15 +278,15 @@ where
|
||||
let data = addr_of_mut!(FORK_EXECUTOR_GLOBAL_DATA);
|
||||
write_volatile(
|
||||
addr_of_mut!((*data).executor_ptr),
|
||||
core::ptr::from_ref(self) as *const c_void,
|
||||
ptr::from_ref(self) as *const c_void,
|
||||
);
|
||||
write_volatile(
|
||||
addr_of_mut!((*data).current_input_ptr),
|
||||
core::ptr::from_ref(input) as *const c_void,
|
||||
ptr::from_ref(input) as *const c_void,
|
||||
);
|
||||
write_volatile(
|
||||
addr_of_mut!((*data).state_ptr),
|
||||
core::ptr::from_mut(state) as *mut c_void,
|
||||
ptr::from_mut(state) as *mut c_void,
|
||||
);
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
}
|
||||
|
@ -497,17 +497,13 @@ pub mod pybind {
|
||||
impl HasObservers for PythonExecutor {
|
||||
#[inline]
|
||||
fn observers(&self) -> &PythonObserversTuple {
|
||||
let ptr = unwrap_me!(self.wrapper, e, {
|
||||
core::ptr::from_ref::<PythonObserversTuple>(e.observers())
|
||||
});
|
||||
let ptr = unwrap_me!(self.wrapper, e, { core::ptr::from_ref(e.observers()) });
|
||||
unsafe { ptr.as_ref().unwrap() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn observers_mut(&mut self) -> &mut PythonObserversTuple {
|
||||
let ptr = unwrap_me_mut!(self.wrapper, e, {
|
||||
core::ptr::from_mut::<PythonObserversTuple>(e.observers_mut())
|
||||
});
|
||||
let ptr = unwrap_me_mut!(self.wrapper, e, { core::ptr::from_mut(e.observers_mut()) });
|
||||
unsafe { ptr.as_mut().unwrap() }
|
||||
}
|
||||
}
|
||||
|
@ -1097,6 +1097,7 @@ impl From<bool> for ConstFeedback {
|
||||
#[allow(clippy::unnecessary_fallible_conversions)]
|
||||
#[allow(missing_docs)]
|
||||
pub mod pybind {
|
||||
use core::ptr;
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
use libafl_bolts::Named;
|
||||
@ -1187,9 +1188,9 @@ pub mod pybind {
|
||||
// # Safety
|
||||
// We use this observer in Python ony when the ObserverTuple is PythonObserversTuple
|
||||
let dont_look_at_this: &PythonObserversTuple =
|
||||
unsafe { &*(core::ptr::from_ref::<OT>(observers) as *const PythonObserversTuple) };
|
||||
unsafe { &*(ptr::from_ref(observers) as *const PythonObserversTuple) };
|
||||
let dont_look_at_this2: &PythonEventManager =
|
||||
unsafe { &*(core::ptr::from_mut::<EM>(manager) as *const PythonEventManager) };
|
||||
unsafe { &*(ptr::from_mut(manager) as *const PythonEventManager) };
|
||||
Ok(Python::with_gil(|py| -> PyResult<bool> {
|
||||
let r: bool = self
|
||||
.inner
|
||||
@ -1221,7 +1222,7 @@ pub mod pybind {
|
||||
// # Safety
|
||||
// We use this observer in Python ony when the ObserverTuple is PythonObserversTuple
|
||||
let dont_look_at_this: &PythonObserversTuple =
|
||||
unsafe { &*(core::ptr::from_ref::<OT>(observers) as *const PythonObserversTuple) };
|
||||
unsafe { &*(ptr::from_ref(observers) as *const PythonObserversTuple) };
|
||||
Python::with_gil(|py| -> PyResult<()> {
|
||||
self.inner.call_method1(
|
||||
py,
|
||||
|
@ -1407,15 +1407,13 @@ pub mod pybind {
|
||||
impl Monitor for PythonMonitor {
|
||||
fn client_stats_mut(&mut self) -> &mut Vec<ClientStats> {
|
||||
let ptr = unwrap_me_mut!(self.wrapper, m, {
|
||||
core::ptr::from_mut::<Vec<ClientStats>>(m.client_stats_mut())
|
||||
core::ptr::from_mut(m.client_stats_mut())
|
||||
});
|
||||
unsafe { ptr.as_mut().unwrap() }
|
||||
}
|
||||
|
||||
fn client_stats(&self) -> &[ClientStats] {
|
||||
let ptr = unwrap_me!(self.wrapper, m, {
|
||||
core::ptr::from_ref::<[ClientStats]>(m.client_stats())
|
||||
});
|
||||
let ptr = unwrap_me!(self.wrapper, m, { core::ptr::from_ref(m.client_stats()) });
|
||||
unsafe { ptr.as_ref().unwrap() }
|
||||
}
|
||||
|
||||
|
@ -593,6 +593,7 @@ where
|
||||
#[cfg(feature = "python")]
|
||||
#[allow(missing_docs)]
|
||||
pub mod pybind {
|
||||
use core::ptr;
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
use libafl_bolts::{
|
||||
@ -1047,7 +1048,7 @@ pub mod pybind {
|
||||
|
||||
impl Named for PythonObserver {
|
||||
fn name(&self) -> &str {
|
||||
let ptr = unwrap_me!(self.wrapper, o, { core::ptr::from_ref::<str>(o.name()) });
|
||||
let ptr = unwrap_me!(self.wrapper, o, { ptr::from_ref::<str>(o.name()) });
|
||||
unsafe { ptr.as_ref().unwrap() }
|
||||
}
|
||||
}
|
||||
@ -1266,7 +1267,7 @@ pub mod pybind {
|
||||
}
|
||||
PythonObserverWrapper::Python(py_wrapper) => {
|
||||
if type_eq::<PyObjectObserver, T>() && py_wrapper.name() == name {
|
||||
r = (core::ptr::from_ref(py_wrapper) as *const T).as_ref();
|
||||
r = (ptr::from_ref(py_wrapper) as *const T).as_ref();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1352,14 +1353,13 @@ pub mod pybind {
|
||||
if type_eq::<PythonMapObserverU64, T>()
|
||||
&& py_wrapper.borrow(py).name() == name
|
||||
{
|
||||
r = (std::ptr::addr_of!(*(*py_wrapper).borrow_mut(py))
|
||||
as *mut T)
|
||||
r = (ptr::addr_of!(*(*py_wrapper).borrow_mut(py)) as *mut T)
|
||||
.as_mut();
|
||||
}
|
||||
}
|
||||
PythonObserverWrapper::Python(py_wrapper) => {
|
||||
if type_eq::<PyObjectObserver, T>() && py_wrapper.name() == name {
|
||||
r = (core::ptr::from_mut(py_wrapper) as *mut T).as_mut();
|
||||
r = (ptr::from_mut(py_wrapper) as *mut T).as_mut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ impl AsanRuntime {
|
||||
interceptor.replace(
|
||||
frida_gum::Module::find_export_by_name($lib, stringify!($name)).expect("Failed to find function"),
|
||||
NativePointer([<replacement_ $name>] as *mut c_void),
|
||||
NativePointer(self as *mut _ as *mut c_void)
|
||||
NativePointer(core::ptr::from_mut(self) as *mut c_void)
|
||||
).ok();
|
||||
}
|
||||
}
|
||||
@ -590,7 +590,7 @@ impl AsanRuntime {
|
||||
interceptor.replace(
|
||||
frida_gum::Module::find_export_by_name($lib, stringify!($name)).expect("Failed to find function"),
|
||||
NativePointer([<replacement_ $name>] as *mut c_void),
|
||||
NativePointer(self as *mut _ as *mut c_void)
|
||||
NativePointer(core::ptr::from_mut(self) as *mut c_void)
|
||||
).ok();
|
||||
}
|
||||
}
|
||||
@ -1942,7 +1942,7 @@ impl AsanRuntime {
|
||||
;->accessed_address:
|
||||
; .dword 0x0
|
||||
; self_addr:
|
||||
; .qword core::ptr::from_mut(self) as *mut c_void as i64
|
||||
; .qword core::ptr::from_mut(self) as *mut c_void as i64
|
||||
; self_regs_addr:
|
||||
; .qword addr_of_mut!(self.regs) as i64
|
||||
; trap_func:
|
||||
@ -2041,7 +2041,7 @@ impl AsanRuntime {
|
||||
; br x1 // go back to the 'return address'
|
||||
|
||||
; self_addr:
|
||||
; .qword self as *mut _ as *mut c_void as i64
|
||||
; .qword core::ptr::from_mut(self) as *mut c_void as i64
|
||||
; self_regs_addr:
|
||||
; .qword addr_of_mut!(self.regs) as i64
|
||||
; trap_func:
|
||||
|
@ -247,7 +247,7 @@ impl CmpLogRuntime {
|
||||
; ldp x2, x3, [sp], #0x10
|
||||
; b >done
|
||||
; self_addr:
|
||||
; .qword self as *mut _ as *mut c_void as i64
|
||||
; .qword core::ptr::from_mut(self) as *mut c_void as i64
|
||||
; populate_lists:
|
||||
; .qword CmpLogRuntime::populate_lists as *mut c_void as i64
|
||||
; done:
|
||||
|
@ -90,11 +90,11 @@ impl<T> __IncompleteArrayField<T> {
|
||||
}
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const T {
|
||||
self as *const _ as *const T
|
||||
core::ptr::from_ref(self) as *const T
|
||||
}
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut T {
|
||||
self as *mut _ as *mut T
|
||||
core::ptr::from_mut(self) as *mut T
|
||||
}
|
||||
#[inline]
|
||||
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
|
||||
|
@ -1,4 +1,6 @@
|
||||
//! A `QEMU`-based executor for binary-only instrumentation in `LibAFL`
|
||||
#[cfg(emulation_mode = "usermode")]
|
||||
use core::ptr;
|
||||
use core::{
|
||||
ffi::c_void,
|
||||
fmt::{self, Debug, Formatter},
|
||||
@ -79,8 +81,8 @@ pub unsafe fn inproc_qemu_crash_handler<E, EM, OF, Z>(
|
||||
Z: HasObjective<Objective = OF, State = E::State>,
|
||||
{
|
||||
let puc = match &mut context {
|
||||
Some(v) => core::ptr::from_mut::<ucontext_t>(*v) as *mut c_void,
|
||||
None => core::ptr::null_mut(),
|
||||
Some(v) => ptr::from_mut::<ucontext_t>(*v) as *mut c_void,
|
||||
None => ptr::null_mut(),
|
||||
};
|
||||
libafl_qemu_handle_crash(signal as i32, info, puc);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ use alloc::{alloc::alloc_zeroed, boxed::Box, vec::Vec};
|
||||
use core::{
|
||||
alloc::Layout,
|
||||
fmt::{self, Debug, Formatter},
|
||||
mem, ptr, slice,
|
||||
};
|
||||
|
||||
use libafl::{
|
||||
@ -480,10 +481,7 @@ impl Serialize for AFLppCmpLogMap {
|
||||
S: Serializer,
|
||||
{
|
||||
let slice = unsafe {
|
||||
core::slice::from_raw_parts(
|
||||
(core::ptr::from_ref::<Self>(self)) as *const u8,
|
||||
core::mem::size_of::<Self>(),
|
||||
)
|
||||
slice::from_raw_parts(ptr::from_ref(self) as *const u8, mem::size_of::<Self>())
|
||||
};
|
||||
serializer.serialize_bytes(slice)
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ fn libnoaslr() -> Result<()> {
|
||||
libc::P_PID,
|
||||
0,
|
||||
libc::PROC_ASLR_CTL,
|
||||
&mut status as *mut i32 as *mut libc::c_void,
|
||||
&mut core::ptr::from_mut(status) as *mut libc::c_void,
|
||||
) < 0
|
||||
{
|
||||
return Err(anyhow!("Failed to set aslr control"));
|
||||
|
@ -36,7 +36,7 @@ fn disable_aslr() -> Result<()> {
|
||||
libc::P_PID,
|
||||
0,
|
||||
libc::PROC_ASLR_CTL,
|
||||
&mut status as *mut i32 as *mut libc::c_void,
|
||||
&mut core::ptr::from_mut(status) as *mut libc::c_void,
|
||||
)
|
||||
};
|
||||
if r < 0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user