From fee9cae8edf6a2e2fea166121080d087c2529e2d Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Mon, 21 Jun 2021 11:58:04 +0200 Subject: [PATCH] Fix InProcessExecutor test mod --- libafl/src/executors/inprocess.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/libafl/src/executors/inprocess.rs b/libafl/src/executors/inprocess.rs index 30bd65f3c9..31cf9a3a0a 100644 --- a/libafl/src/executors/inprocess.rs +++ b/libafl/src/executors/inprocess.rs @@ -15,6 +15,11 @@ use crate::bolts::os::unix_signals::setup_signal_handler; #[cfg(all(windows, feature = "std"))] use crate::bolts::os::windows_exceptions::setup_exception_handler; +#[cfg(unix)] +pub use unix_signal_handler::{nop_handler, HandlerFuncPtr}; +#[cfg(all(windows, feature = "std"))] +pub use windows_exception_handler::{nop_handler, HandlerFuncPtr}; + use crate::{ corpus::Corpus, events::{EventFirer, EventRestarter}, @@ -39,14 +44,11 @@ where /// The observers, observing each run observers: OT, /// On crash C function pointer - #[cfg(unix)] - crash_handler: unix_signal_handler::HandlerFuncPtr, + #[cfg(any(unix, all(windows, feature = "std")))] + crash_handler: HandlerFuncPtr, /// On timeout C function pointer #[cfg(unix)] - timeout_handler: unix_signal_handler::HandlerFuncPtr, - /// On crash C function pointer - #[cfg(all(windows, feature = "std"))] - crash_handler: windows_exception_handler::HandlerFuncPtr, + timeout_handler: HandlerFuncPtr, phantom: PhantomData<(I, S)>, } @@ -301,7 +303,7 @@ mod unix_signal_handler { unsafe impl Send for InProcessExecutorHandlerData {} unsafe impl Sync for InProcessExecutorHandlerData {} - unsafe fn nop_handler( + pub unsafe fn nop_handler( _signal: Signal, _info: siginfo_t, _context: &mut ucontext_t, @@ -605,7 +607,7 @@ mod windows_exception_handler { unsafe impl Send for InProcessExecutorHandlerData {} unsafe impl Sync for InProcessExecutorHandlerData {} - unsafe fn nop_handler( + pub unsafe fn nop_handler( _code: ExceptionCode, _exception_pointers: *mut EXCEPTION_POINTERS, _data: &mut InProcessExecutorHandlerData, @@ -728,7 +730,7 @@ mod tests { use crate::{ bolts::tuples::tuple_list, - executors::{Executor, ExitKind, InProcessExecutor}, + executors::{inprocess, Executor, ExitKind, InProcessExecutor}, inputs::NopInput, }; @@ -739,6 +741,10 @@ mod tests { let mut in_process_executor = InProcessExecutor::<_, NopInput, (), ()> { harness_fn: &mut harness, observers: tuple_list!(), + #[cfg(any(unix, all(windows, feature = "std")))] + crash_handler: inprocess::nop_handler, + #[cfg(unix)] + timeout_handler: inprocess::nop_handler, phantom: PhantomData, }; let input = NopInput {};