diff --git a/fuzzer/Cargo.toml b/fuzzer/Cargo.toml index 9ea13ec3..52f8bfc5 100644 --- a/fuzzer/Cargo.toml +++ b/fuzzer/Cargo.toml @@ -19,7 +19,7 @@ byteorder = "1.2" chrono = "0.4" priority-queue = "0.6" num_cpus = "1.0" -derive_more = "0.15" +derive_more = "0.99" colored = "1.6" serde="1.0" serde_derive = "1.0" diff --git a/fuzzer/src/bind_cpu.rs b/fuzzer/src/bind_cpu.rs index a18753e7..adb27760 100644 --- a/fuzzer/src/bind_cpu.rs +++ b/fuzzer/src/bind_cpu.rs @@ -94,9 +94,8 @@ pub fn bind_thread_to_cpu_core(_cid: usize) { #[cfg(target_os = "linux")] pub fn bind_thread_to_cpu_core(cid: usize) { - // let tid = unsafe { libc::pthread_self() }; unsafe { - let mut c: libc::cpu_set_t = mem::uninitialized(); + let mut c: libc::cpu_set_t = mem::zeroed(); libc::CPU_ZERO(&mut c); libc::CPU_SET(cid, &mut c); if libc::sched_setaffinity(0, mem::size_of_val(&c), &c as *const libc::cpu_set_t) != 0 { diff --git a/fuzzer/src/executor/limit.rs b/fuzzer/src/executor/limit.rs index 3cad99cc..0ff18308 100644 --- a/fuzzer/src/executor/limit.rs +++ b/fuzzer/src/executor/limit.rs @@ -40,7 +40,7 @@ impl SetLimit for Command { Ok(()) }; - self.before_exec(func) + unsafe { self.pre_exec(func) } } fn setsid(&mut self) -> &mut Self { @@ -50,7 +50,7 @@ impl SetLimit for Command { }; Ok(()) }; - self.before_exec(func) + unsafe { self.pre_exec(func) } } fn pipe_stdin(&mut self, fd: RawFd, is_stdin: bool) -> &mut Self { @@ -65,7 +65,7 @@ impl SetLimit for Command { } Ok(()) }; - self.before_exec(func) + unsafe { self.pre_exec(func) } } else { self } diff --git a/fuzzer/src/track/load_pin_data.rs b/fuzzer/src/track/load_pin_data.rs index 712ef187..0db602ef 100644 --- a/fuzzer/src/track/load_pin_data.rs +++ b/fuzzer/src/track/load_pin_data.rs @@ -4,38 +4,26 @@ use angora_common::tag::TagSeg; use std::fs::File; use std::io::{self, Read}; use std::{collections::HashMap, path::Path}; +use std::mem::MaybeUninit; +use std; fn read_struct(mut read: R) -> io::Result { - let num_bytes = ::std::mem::size_of::(); - unsafe { - let mut s = ::std::mem::uninitialized(); - let buffer = ::std::slice::from_raw_parts_mut(&mut s as *mut T as *mut u8, num_bytes); - match read.read_exact(buffer) { - Ok(()) => Ok(s), - Err(e) => { - ::std::mem::forget(s); - Err(e) - } - } - } + let mut obj = MaybeUninit::::uninit(); + let num_bytes = std::mem::size_of::(); + let buffer = unsafe{ std::slice::from_raw_parts_mut(obj.as_mut_ptr() as *mut u8, num_bytes) }; + read.read_exact(buffer)?; + Ok(unsafe { obj.assume_init() }) } fn read_vector(mut read: R, size: usize) -> io::Result> { let mut vec = Vec::::with_capacity(size); if size > 0 { - unsafe { - vec.set_len(size); - let num_bytes = ::std::mem::size_of::() * size; - let buffer = - ::std::slice::from_raw_parts_mut((&mut vec[..]).as_ptr() as *mut u8, num_bytes); - match read.read_exact(buffer) { - Ok(()) => Ok(vec), - Err(e) => Err(e), - } - } - } else { - Ok(vec) - } + let num_bytes = std::mem::size_of::() * size; + unsafe { vec.set_len(size) }; + let buffer = unsafe {std::slice::from_raw_parts_mut((&mut vec[..]).as_mut_ptr() as *mut u8, num_bytes) } ; + read.read_exact(buffer)?; + } + Ok(vec) } pub fn get_log_data_pin(out_f: &Path) -> io::Result { diff --git a/runtime_fast/src/fast.rs b/runtime_fast/src/fast.rs index 0535ac5c..8b46c9f9 100644 --- a/runtime_fast/src/fast.rs +++ b/runtime_fast/src/fast.rs @@ -1,8 +1,9 @@ use super::{shm_conds, forkcli, shm_branches}; use std::ops::DerefMut; -use std::sync::{Once, ONCE_INIT}; -static START: Once = ONCE_INIT; +use std::sync::Once; + +static START: Once = Once::new(); #[ctor] fn fast_init() {