bolts: fix static mutable use (#1793)
This commit is contained in:
parent
c240cdec38
commit
61718c4e88
@ -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");
|
||||
|
@ -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 {
|
||||
|
@ -436,7 +436,7 @@ static mut CTRL_HANDLER: Option<CtrlHandlerHolder> = None;
|
||||
/// # Safety
|
||||
/// Same safety considerations as in `setup_exception_handler`
|
||||
pub(crate) unsafe fn setup_ctrl_handler<T: 'static + CtrlHandler>(
|
||||
handler: &mut T,
|
||||
handler: *mut T,
|
||||
) -> Result<(), Error> {
|
||||
write_volatile(
|
||||
&mut CTRL_HANDLER,
|
||||
|
Loading…
x
Reference in New Issue
Block a user