From 38368c121b3eced62138a907ea694933e942bc06 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Thu, 18 Mar 2021 16:45:54 +0100 Subject: [PATCH] fixes for win32 --- libafl/src/bolts/os/windows_exceptions.rs | 12 +++++------- libafl/src/bolts/shmem.rs | 3 ++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libafl/src/bolts/os/windows_exceptions.rs b/libafl/src/bolts/os/windows_exceptions.rs index f54ebcc83c..a551364dc5 100644 --- a/libafl/src/bolts/os/windows_exceptions.rs +++ b/libafl/src/bolts/os/windows_exceptions.rs @@ -195,7 +195,7 @@ unsafe extern "system" fn handle_exception(exception_pointers: *mut EXCEPTION_PO } None => EXCEPTION_CONTINUE_EXECUTION, }; - if let Some(prev_handler) = unsafe { PREVIOUS_HANDLER } { + if let Some(prev_handler) = PREVIOUS_HANDLER { prev_handler(exception_pointers) } else { ret @@ -215,12 +215,10 @@ pub unsafe fn setup_exception_handler(handler: &mut T) -> } compiler_fence(Ordering::SeqCst); - unsafe { - if let Some(prev) = SetUnhandledExceptionFilter(Some(core::mem::transmute( - handle_exception as *const c_void, - ))) { - PREVIOUS_HANDLER = Some(core::mem::transmute(prev as *const c_void)); - } + if let Some(prev) = SetUnhandledExceptionFilter(Some(core::mem::transmute( + handle_exception as *const c_void, + ))) { + PREVIOUS_HANDLER = Some(core::mem::transmute(prev as *const c_void)); } Ok(()) } diff --git a/libafl/src/bolts/shmem.rs b/libafl/src/bolts/shmem.rs index 0f745ad946..4eb9f5ed2d 100644 --- a/libafl/src/bolts/shmem.rs +++ b/libafl/src/bolts/shmem.rs @@ -540,7 +540,8 @@ pub mod shmem { pub fn new(map_size: usize) -> Result { let uuid = Uuid::new_v4(); - let mut map_str_bytes = format!("libafl_{}", uuid.to_simple()).as_mut_vec(); + let mut map_str = format!("libafl_{}", uuid.to_simple()); + let map_str_bytes = map_str.as_mut_vec(); map_str_bytes[19] = 0; // Trucate to size 20 unsafe { let handle = CreateFileMappingA(