From b385b43e7e00140972df4d834c7bd7851e7f75d8 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Fri, 5 Feb 2021 03:31:40 +0100 Subject: [PATCH] win for the win --- afl/src/events/mod.rs | 2 ++ afl/src/executors/inmemory.rs | 4 ++++ afl/src/shmem.rs | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/afl/src/events/mod.rs b/afl/src/events/mod.rs index d55063373d..b6208e0f3f 100644 --- a/afl/src/events/mod.rs +++ b/afl/src/events/mod.rs @@ -11,6 +11,7 @@ use core::{ use serde::{Deserialize, Serialize}; #[cfg(feature = "std")] +#[cfg(unix)] use crate::shmem::AflShmem; use crate::{ corpus::Corpus, @@ -718,6 +719,7 @@ where } #[cfg(feature = "std")] +#[cfg(unix)] impl LlmpEventManager where I: Input, diff --git a/afl/src/executors/inmemory.rs b/afl/src/executors/inmemory.rs index 5df99777b3..64ddd01bd5 100644 --- a/afl/src/executors/inmemory.rs +++ b/afl/src/executors/inmemory.rs @@ -1,5 +1,6 @@ use core::marker::PhantomData; #[cfg(feature = "std")] +#[cfg(unix)] use os_signals::set_oncrash_ptrs; use crate::{ @@ -20,8 +21,10 @@ use crate::{ use unix_signals as os_signals; #[cfg(feature = "std")] +#[cfg(unix)] use self::os_signals::reset_oncrash_ptrs; #[cfg(feature = "std")] +#[cfg(unix)] use self::os_signals::setup_crash_handlers; /// The inmem executor harness @@ -150,6 +153,7 @@ where EM: EventManager, { #[cfg(feature = "std")] + #[cfg(unix)] unsafe { setup_crash_handlers::(); } diff --git a/afl/src/shmem.rs b/afl/src/shmem.rs index a531371a71..b9de3e70ab 100644 --- a/afl/src/shmem.rs +++ b/afl/src/shmem.rs @@ -2,6 +2,7 @@ // too.) #[cfg(feature = "std")] +#[cfg(unix)] pub use shmem::AflShmem; use alloc::string::{String, ToString}; @@ -95,6 +96,7 @@ pub trait ShMem: Sized + Debug { } } +#[cfg(unix)] #[cfg(feature = "std")] pub mod shmem { @@ -106,6 +108,7 @@ pub mod shmem { use super::ShMem; + #[cfg(unix)] extern "C" { #[cfg(feature = "std")] fn snprintf(_: *mut c_char, _: c_ulong, _: *const c_char, _: ...) -> c_int; @@ -119,6 +122,7 @@ pub mod shmem { fn shmat(__shmid: c_int, __shmaddr: *const c_void, __shmflg: c_int) -> *mut c_void; } + #[cfg(unix)] #[derive(Copy, Clone)] #[repr(C)] struct ipc_perm { @@ -135,6 +139,7 @@ pub mod shmem { pub __glibc_reserved2: c_ulong, } + #[cfg(unix)] #[derive(Copy, Clone)] #[repr(C)] struct shmid_ds { @@ -151,6 +156,7 @@ pub mod shmem { } /// The default Sharedmap impl for unix using shmctl & shmget + #[cfg(unix)] #[derive(Clone, Debug)] pub struct AflShmem { pub shm_str: [u8; 20], @@ -159,6 +165,7 @@ pub mod shmem { pub map_size: usize, } + #[cfg(unix)] impl ShMem for AflShmem { fn existing_from_shm_slice( map_str_bytes: &[u8; 20], @@ -197,6 +204,7 @@ pub mod shmem { } /// Create an uninitialized shmap + #[cfg(unix)] const fn afl_shmem_unitialized() -> AflShmem { AflShmem { shm_str: [0; 20], @@ -206,6 +214,7 @@ pub mod shmem { } } + #[cfg(unix)] impl AflShmem { pub fn from_str(shm_str: &CStr, map_size: usize) -> Result { let mut ret = afl_shmem_unitialized();