diff --git a/libafl_bolts/src/lib.rs b/libafl_bolts/src/lib.rs index b0a9d5cca5..5322d392e1 100644 --- a/libafl_bolts/src/lib.rs +++ b/libafl_bolts/src/lib.rs @@ -168,6 +168,8 @@ use alloc::vec::Vec; use core::hash::BuildHasher; #[cfg(any(feature = "xxh3", feature = "alloc"))] use core::hash::Hasher; +#[cfg(all(unix, feature = "std"))] +use core::ptr; #[cfg(feature = "std")] use std::time::{SystemTime, UNIX_EPOCH}; #[cfg(all(unix, feature = "std"))] @@ -940,7 +942,7 @@ impl SimpleFdLogger { // We also access a shared variable here. unsafe { LIBAFL_RAWFD_LOGGER.set_fd(log_fd); - log::set_logger(&LIBAFL_RAWFD_LOGGER)?; + log::set_logger(&*ptr::addr_of!(LIBAFL_RAWFD_LOGGER))?; } Ok(()) } @@ -1150,6 +1152,9 @@ pub mod pybind { #[cfg(test)] mod tests { + #[cfg(all(feature = "std", unix))] + use core::ptr; + #[cfg(all(feature = "std", unix))] use crate::LIBAFL_RAWFD_LOGGER; @@ -1160,7 +1165,7 @@ mod tests { unsafe { LIBAFL_RAWFD_LOGGER.fd = stdout().as_raw_fd() }; unsafe { - log::set_logger(&LIBAFL_RAWFD_LOGGER).unwrap(); + log::set_logger(&*ptr::addr_of!(LIBAFL_RAWFD_LOGGER)).unwrap(); } log::set_max_level(log::LevelFilter::Debug); log::info!("Test"); diff --git a/libafl_bolts/src/llmp.rs b/libafl_bolts/src/llmp.rs index dca1a8f7e7..49a0609b9f 100644 --- a/libafl_bolts/src/llmp.rs +++ b/libafl_bolts/src/llmp.rs @@ -2267,7 +2267,9 @@ where #[cfg(any(all(unix, not(miri)), all(windows, feature = "std")))] fn setup_handlers() { #[cfg(all(unix, not(miri)))] - if let Err(e) = unsafe { setup_signal_handler(&mut LLMP_SIGHANDLER_STATE) } { + if let Err(e) = + unsafe { setup_signal_handler(&mut *ptr::addr_of_mut!(LLMP_SIGHANDLER_STATE)) } + { // We can live without a proper ctrl+c signal handler - Ignore. log::info!("Failed to setup signal handlers: {e}"); } else { @@ -2275,7 +2277,7 @@ where } #[cfg(all(windows, feature = "std"))] - if let Err(e) = unsafe { setup_ctrl_handler(&mut LLMP_SIGHANDLER_STATE) } { + if let Err(e) = unsafe { setup_ctrl_handler(ptr::addr_of_mut!(LLMP_SIGHANDLER_STATE)) } { // We can live without a proper ctrl+c signal handler - Ignore. log::info!("Failed to setup control handlers: {e}"); } else { diff --git a/libafl_bolts/src/os/windows_exceptions.rs b/libafl_bolts/src/os/windows_exceptions.rs index ffc092de38..e914a14dbd 100644 --- a/libafl_bolts/src/os/windows_exceptions.rs +++ b/libafl_bolts/src/os/windows_exceptions.rs @@ -436,7 +436,7 @@ static mut CTRL_HANDLER: Option = None; /// # Safety /// Same safety considerations as in `setup_exception_handler` pub(crate) unsafe fn setup_ctrl_handler( - handler: &mut T, + handler: *mut T, ) -> Result<(), Error> { write_volatile( &mut CTRL_HANDLER,