more clippy
This commit is contained in:
parent
d72d48d6a8
commit
ec55a03ec1
@ -1,14 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Clippy checks
|
# Clippy checks
|
||||||
cargo clean
|
cargo clean -p libafl
|
||||||
RUST_BACKTRACE=full cargo clippy --all -- \
|
RUST_BACKTRACE=full cargo clippy --all -- \
|
||||||
-D clippy::pedantic \
|
-D clippy::pedantic \
|
||||||
-W clippy::cast_sign_loss \
|
-W clippy::cast_sign_loss \
|
||||||
-W clippy::similar-names \
|
-W clippy::similar-names \
|
||||||
-W clippy::cast_ptr_alignment \
|
-W clippy::cast_ptr_alignment \
|
||||||
|
-W clippy::cast_possible_wrap \
|
||||||
|
-W clippy::unused_self \
|
||||||
|
-W clippy::too_many_lines \
|
||||||
-A missing-docs \
|
-A missing-docs \
|
||||||
-A clippy::doc_markdown \
|
-A clippy::doc_markdown \
|
||||||
-A clippy::must-use-candidate \
|
-A clippy::must-use-candidate \
|
||||||
|
-A clippy::type_repetition_in_bounds \
|
||||||
-A clippy::missing-errors-doc \
|
-A clippy::missing-errors-doc \
|
||||||
-A clippy::cast-possible-truncation \
|
-A clippy::cast-possible-truncation \
|
||||||
-A clippy::used-underscore-binding \
|
-A clippy::used-underscore-binding \
|
||||||
|
@ -1223,6 +1223,7 @@ where
|
|||||||
/// Will return IllegalArgument error if msg is not on page.
|
/// Will return IllegalArgument error if msg is not on page.
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// This dereferences msg, make sure to pass a proper pointer to it.
|
/// This dereferences msg, make sure to pass a proper pointer to it.
|
||||||
|
#[allow(clippy::cast_sign_loss)]
|
||||||
pub unsafe fn msg_to_offset(&self, msg: *const LlmpMsg) -> Result<u64, Error> {
|
pub unsafe fn msg_to_offset(&self, msg: *const LlmpMsg) -> Result<u64, Error> {
|
||||||
let page = self.page();
|
let page = self.page();
|
||||||
if llmp_msg_in_page(page, msg) {
|
if llmp_msg_in_page(page, msg) {
|
||||||
@ -1266,19 +1267,17 @@ where
|
|||||||
/// Gets this message from this page, at the indicated offset.
|
/// Gets this message from this page, at the indicated offset.
|
||||||
/// Will return IllegalArgument error if the offset is out of bounds.
|
/// Will return IllegalArgument error if the offset is out of bounds.
|
||||||
pub fn msg_from_offset(&mut self, offset: u64) -> Result<*mut LlmpMsg, Error> {
|
pub fn msg_from_offset(&mut self, offset: u64) -> Result<*mut LlmpMsg, Error> {
|
||||||
|
let offset = offset as usize;
|
||||||
unsafe {
|
unsafe {
|
||||||
let page = self.page_mut();
|
let page = self.page_mut();
|
||||||
let page_size = self.shmem.map().len() - size_of::<LlmpPage>();
|
let page_size = self.shmem.map().len() - size_of::<LlmpPage>();
|
||||||
if offset as isize > page_size as isize {
|
if offset > page_size {
|
||||||
Err(Error::IllegalArgument(format!(
|
Err(Error::IllegalArgument(format!(
|
||||||
"Msg offset out of bounds (size: {}, requested offset: {})",
|
"Msg offset out of bounds (size: {}, requested offset: {})",
|
||||||
page_size, offset
|
page_size, offset
|
||||||
)))
|
)))
|
||||||
} else {
|
} else {
|
||||||
Ok(
|
Ok(((*page).messages.as_mut_ptr() as *mut u8).add(offset) as *mut LlmpMsg)
|
||||||
((*page).messages.as_mut_ptr() as *mut u8).offset(offset as isize)
|
|
||||||
as *mut LlmpMsg,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1310,7 +1309,7 @@ pub struct LlmpBrokerSignalHandler {
|
|||||||
|
|
||||||
#[cfg(all(unix))]
|
#[cfg(all(unix))]
|
||||||
impl Handler for LlmpBrokerSignalHandler {
|
impl Handler for LlmpBrokerSignalHandler {
|
||||||
fn handle(&mut self, _signal: Signal, _info: siginfo_t, _void: c_void) {
|
fn handle(&mut self, _signal: Signal, _info: siginfo_t, _void: *const c_void) {
|
||||||
unsafe { ptr::write_volatile(&mut self.shutting_down, true) };
|
unsafe { ptr::write_volatile(&mut self.shutting_down, true) };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1400,6 +1399,7 @@ where
|
|||||||
/// Internal function, returns true when shuttdown is requested by a `SIGINT` signal
|
/// Internal function, returns true when shuttdown is requested by a `SIGINT` signal
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
#[allow(clippy::unused_self)]
|
||||||
fn is_shutting_down(&self) -> bool {
|
fn is_shutting_down(&self) -> bool {
|
||||||
unsafe { ptr::read_volatile(&GLOBAL_SIGHANDLER_STATE.shutting_down) }
|
unsafe { ptr::read_volatile(&GLOBAL_SIGHANDLER_STATE.shutting_down) }
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ impl Display for Signal {
|
|||||||
|
|
||||||
pub trait Handler {
|
pub trait Handler {
|
||||||
/// Handle a signal
|
/// Handle a signal
|
||||||
fn handle(&mut self, signal: Signal, info: siginfo_t, _void: c_void);
|
fn handle(&mut self, signal: Signal, info: siginfo_t, _void: *const c_void);
|
||||||
/// Return a list of signals to handle
|
/// Return a list of signals to handle
|
||||||
fn signals(&self) -> Vec<Signal>;
|
fn signals(&self) -> Vec<Signal>;
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ static mut SIGNAL_HANDLERS: [Option<HandlerHolder>; 32] = [
|
|||||||
/// # Safety
|
/// # Safety
|
||||||
/// This should be somewhat safe to call for signals previously registered,
|
/// This should be somewhat safe to call for signals previously registered,
|
||||||
/// unless the signal handlers registered using [setup_signal_handler] are broken.
|
/// unless the signal handlers registered using [setup_signal_handler] are broken.
|
||||||
unsafe fn handle_signal(sig: c_int, info: siginfo_t, void: c_void) {
|
unsafe fn handle_signal(sig: c_int, info: siginfo_t, void: *const c_void) {
|
||||||
let signal = &Signal::try_from(sig).unwrap();
|
let signal = &Signal::try_from(sig).unwrap();
|
||||||
let handler = {
|
let handler = {
|
||||||
match &SIGNAL_HANDLERS[*signal as usize] {
|
match &SIGNAL_HANDLERS[*signal as usize] {
|
||||||
|
@ -277,7 +277,7 @@ macro_rules! create_serde_registry_for_trait {
|
|||||||
None => None,
|
None => None,
|
||||||
Some(h) => h
|
Some(h) => h
|
||||||
.get(&xxhash_rust::xxh3::xxh3_64(name.as_bytes()))
|
.get(&xxhash_rust::xxh3::xxh3_64(name.as_bytes()))
|
||||||
.map(|x| x.as_ref()),
|
.map(AsRef::as_ref),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ macro_rules! create_serde_registry_for_trait {
|
|||||||
None => None,
|
None => None,
|
||||||
Some(h) => h
|
Some(h) => h
|
||||||
.get_mut(&xxhash_rust::xxh3::xxh3_64(name.as_bytes()))
|
.get_mut(&xxhash_rust::xxh3::xxh3_64(name.as_bytes()))
|
||||||
.map(|x| x.as_mut()),
|
.map(AsMut::as_mut),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ pub mod unix_shmem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Deinitialize this shmem instance
|
/// Deinitialize this shmem instance
|
||||||
#[allow(clippy::clippy::clippy::unnecessary_cast)] // for c_ types
|
#[allow(clippy::clippy::unnecessary_cast)] // for c_ types
|
||||||
unsafe fn unix_shmem_deinit(shm: *mut UnixShMem) {
|
unsafe fn unix_shmem_deinit(shm: *mut UnixShMem) {
|
||||||
if shm.is_null() || (*shm).map.is_null() {
|
if shm.is_null() || (*shm).map.is_null() {
|
||||||
/* Serialized map id */
|
/* Serialized map id */
|
||||||
@ -370,7 +370,7 @@ pub mod unix_shmem {
|
|||||||
|
|
||||||
/// Functions to create Shared memory region, for observation channels and
|
/// Functions to create Shared memory region, for observation channels and
|
||||||
/// opening inputs and stuff.
|
/// opening inputs and stuff.
|
||||||
#[allow(clippy::clippy::clippy::unnecessary_cast)] // for c_ types
|
#[allow(clippy::clippy::unnecessary_cast)] // for c_ types
|
||||||
unsafe fn unix_shmem_init(shm: *mut UnixShMem, map_size: usize) -> *mut c_uchar {
|
unsafe fn unix_shmem_init(shm: *mut UnixShMem, map_size: usize) -> *mut c_uchar {
|
||||||
(*shm).map_size = map_size;
|
(*shm).map_size = map_size;
|
||||||
(*shm).map = ptr::null_mut();
|
(*shm).map = ptr::null_mut();
|
||||||
@ -390,8 +390,7 @@ pub mod unix_shmem {
|
|||||||
(*shm).shm_id,
|
(*shm).shm_id,
|
||||||
);
|
);
|
||||||
(*shm).shm_str
|
(*shm).shm_str
|
||||||
[(size_of::<[c_char; 20]>() as c_ulong).wrapping_sub(1 as c_int as c_ulong) as usize] =
|
[(size_of::<[c_char; 20]>() as c_ulong).wrapping_sub(1 as c_ulong) as usize] = 0u8;
|
||||||
0u8;
|
|
||||||
(*shm).map = shmat((*shm).shm_id, ptr::null(), 0 as c_int) as *mut c_uchar;
|
(*shm).map = shmat((*shm).shm_id, ptr::null(), 0 as c_int) as *mut c_uchar;
|
||||||
if (*shm).map == -(1 as c_int) as *mut c_void as *mut c_uchar || (*shm).map.is_null() {
|
if (*shm).map == -(1 as c_int) as *mut c_void as *mut c_uchar || (*shm).map.is_null() {
|
||||||
shmctl((*shm).shm_id, 0 as c_int, ptr::null_mut());
|
shmctl((*shm).shm_id, 0 as c_int, ptr::null_mut());
|
||||||
@ -403,7 +402,7 @@ pub mod unix_shmem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Uses a shmap id string to open a shared map
|
/// Uses a shmap id string to open a shared map
|
||||||
#[allow(clippy::clippy::unnecessary_cast)] // for c_int and c_long
|
#[allow(clippy::unnecessary_cast)] // for c_int and c_long
|
||||||
unsafe fn unix_shmem_by_str(
|
unsafe fn unix_shmem_by_str(
|
||||||
shm: *mut UnixShMem,
|
shm: *mut UnixShMem,
|
||||||
shm_str: &CStr,
|
shm_str: &CStr,
|
||||||
|
@ -150,6 +150,8 @@ where
|
|||||||
C: Corpus<I>,
|
C: Corpus<I>,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
|
/// Update the `Corpus` score using the `MinimizerCorpusScheduler`
|
||||||
|
#[allow(clippy::unused_self)]
|
||||||
pub fn update_score(&self, state: &mut S, idx: usize) -> Result<(), Error> {
|
pub fn update_score(&self, state: &mut S, idx: usize) -> Result<(), Error> {
|
||||||
// Create a new top rated meta if not existing
|
// Create a new top rated meta if not existing
|
||||||
if state.metadata().get::<TopRatedsMetadata>().is_none() {
|
if state.metadata().get::<TopRatedsMetadata>().is_none() {
|
||||||
@ -194,6 +196,8 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Cull the `Corpus` using the `MinimizerCorpusScheduler`
|
||||||
|
#[allow(clippy::unused_self)]
|
||||||
pub fn cull(&self, state: &mut S) -> Result<(), Error> {
|
pub fn cull(&self, state: &mut S) -> Result<(), Error> {
|
||||||
if state.metadata().get::<TopRatedsMetadata>().is_none() {
|
if state.metadata().get::<TopRatedsMetadata>().is_none() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -217,14 +217,15 @@ where
|
|||||||
self.cached_len = Some(l);
|
self.cached_len = Some(l);
|
||||||
l
|
l
|
||||||
}
|
}
|
||||||
None => match self.cached_len {
|
|
||||||
Some(l) => l,
|
|
||||||
None => {
|
None => {
|
||||||
|
if let Some(l) = self.cached_len {
|
||||||
|
l
|
||||||
|
} else {
|
||||||
let l = self.load_input()?.len();
|
let l = self.load_input()?.len();
|
||||||
self.cached_len = Some(l);
|
self.cached_len = Some(l);
|
||||||
l
|
l
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Handle arriving events in the broker
|
/// Handle arriving events in the broker
|
||||||
#[allow(clippy::clippy::unnecessary_wraps)]
|
#[allow(clippy::unnecessary_wraps)]
|
||||||
fn handle_in_broker(
|
fn handle_in_broker(
|
||||||
stats: &mut ST,
|
stats: &mut ST,
|
||||||
sender_id: u32,
|
sender_id: u32,
|
||||||
@ -258,6 +258,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle arriving events in the client
|
// Handle arriving events in the client
|
||||||
|
#[allow(clippy::unused_self)]
|
||||||
fn handle_in_client<CS, E, OT>(
|
fn handle_in_client<CS, E, OT>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut S,
|
state: &mut S,
|
||||||
@ -507,7 +508,11 @@ where
|
|||||||
/// A restarting state is a combination of restarter and runner, that can be used on systems without `fork`.
|
/// A restarting state is a combination of restarter and runner, that can be used on systems without `fork`.
|
||||||
/// The restarter will start a new process each time the child crashes or timeouts.
|
/// The restarter will start a new process each time the child crashes or timeouts.
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
#[allow(clippy::clippy::unnecessary_operation, clippy::clippy::type_complexity)] // for { mgr = LlmpEventManager... }
|
#[allow(
|
||||||
|
clippy::unnecessary_operation,
|
||||||
|
clippy::type_complexity,
|
||||||
|
clippy::similar_names
|
||||||
|
)] // for { mgr = LlmpEventManager... }
|
||||||
pub fn setup_restarting_mgr<I, S, SH, ST>(
|
pub fn setup_restarting_mgr<I, S, SH, ST>(
|
||||||
//mgr: &mut LlmpEventManager<I, S, SH, ST>,
|
//mgr: &mut LlmpEventManager<I, S, SH, ST>,
|
||||||
stats: ST,
|
stats: ST,
|
||||||
|
@ -118,6 +118,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle arriving events in the client
|
// Handle arriving events in the client
|
||||||
|
#[allow(clippy::needless_pass_by_value, clippy::unused_self)]
|
||||||
fn handle_in_client(&mut self, _state: &mut S, event: Event<I>) -> Result<(), Error> {
|
fn handle_in_client(&mut self, _state: &mut S, event: Event<I>) -> Result<(), Error> {
|
||||||
Err(Error::Unknown(format!(
|
Err(Error::Unknown(format!(
|
||||||
"Received illegal message that message should not have arrived: {:?}.",
|
"Received illegal message that message should not have arrived: {:?}.",
|
||||||
|
@ -273,8 +273,8 @@ mod unix_signal_handler {
|
|||||||
pub event_mgr_ptr: *mut c_void,
|
pub event_mgr_ptr: *mut c_void,
|
||||||
pub observers_ptr: *const c_void,
|
pub observers_ptr: *const c_void,
|
||||||
pub current_input_ptr: *const c_void,
|
pub current_input_ptr: *const c_void,
|
||||||
pub crash_handler: unsafe fn(Signal, siginfo_t, c_void, data: &mut Self),
|
pub crash_handler: unsafe fn(Signal, siginfo_t, *const c_void, data: &mut Self),
|
||||||
pub timeout_handler: unsafe fn(Signal, siginfo_t, c_void, data: &mut Self),
|
pub timeout_handler: unsafe fn(Signal, siginfo_t, *const c_void, data: &mut Self),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for InProcessExecutorHandlerData {}
|
unsafe impl Send for InProcessExecutorHandlerData {}
|
||||||
@ -283,14 +283,14 @@ mod unix_signal_handler {
|
|||||||
unsafe fn nop_handler(
|
unsafe fn nop_handler(
|
||||||
_signal: Signal,
|
_signal: Signal,
|
||||||
_info: siginfo_t,
|
_info: siginfo_t,
|
||||||
_void: c_void,
|
_void: *const c_void,
|
||||||
_data: &mut InProcessExecutorHandlerData,
|
_data: &mut InProcessExecutorHandlerData,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
impl Handler for InProcessExecutorHandlerData {
|
impl Handler for InProcessExecutorHandlerData {
|
||||||
fn handle(&mut self, signal: Signal, info: siginfo_t, void: c_void) {
|
fn handle(&mut self, signal: Signal, info: siginfo_t, void: *const c_void) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = &mut GLOBAL_STATE;
|
let data = &mut GLOBAL_STATE;
|
||||||
match signal {
|
match signal {
|
||||||
@ -320,7 +320,7 @@ mod unix_signal_handler {
|
|||||||
pub unsafe fn inproc_timeout_handler<EM, I, OC, OFT, OT, S>(
|
pub unsafe fn inproc_timeout_handler<EM, I, OC, OFT, OT, S>(
|
||||||
_signal: Signal,
|
_signal: Signal,
|
||||||
_info: siginfo_t,
|
_info: siginfo_t,
|
||||||
_void: c_void,
|
_void: *const c_void,
|
||||||
data: &mut InProcessExecutorHandlerData,
|
data: &mut InProcessExecutorHandlerData,
|
||||||
) where
|
) where
|
||||||
EM: EventManager<I, S>,
|
EM: EventManager<I, S>,
|
||||||
@ -382,7 +382,7 @@ mod unix_signal_handler {
|
|||||||
pub unsafe fn inproc_crash_handler<EM, I, OC, OFT, OT, S>(
|
pub unsafe fn inproc_crash_handler<EM, I, OC, OFT, OT, S>(
|
||||||
_signal: Signal,
|
_signal: Signal,
|
||||||
_info: siginfo_t,
|
_info: siginfo_t,
|
||||||
_void: c_void,
|
_void: *const c_void,
|
||||||
data: &mut InProcessExecutorHandlerData,
|
data: &mut InProcessExecutorHandlerData,
|
||||||
) where
|
) where
|
||||||
EM: EventManager<I, S>,
|
EM: EventManager<I, S>,
|
||||||
|
@ -118,7 +118,7 @@ where
|
|||||||
let bit = state.rand_mut().below((input.bytes().len() << 3) as u64) as usize;
|
let bit = state.rand_mut().below((input.bytes().len() << 3) as u64) as usize;
|
||||||
unsafe {
|
unsafe {
|
||||||
// Moar speed, no bound check
|
// Moar speed, no bound check
|
||||||
*input.bytes_mut().get_unchecked_mut(bit >> 3) ^= (128 >> (bit & 7)) as u8;
|
*input.bytes_mut().get_unchecked_mut(bit >> 3) ^= (128u8 >> (bit & 7)) as u8;
|
||||||
}
|
}
|
||||||
Ok(MutationResult::Mutated)
|
Ok(MutationResult::Mutated)
|
||||||
}
|
}
|
||||||
@ -734,6 +734,7 @@ where
|
|||||||
S: HasRand<R>,
|
S: HasRand<R>,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
|
#[allow(clippy::cast_sign_loss)]
|
||||||
fn mutate(
|
fn mutate(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut S,
|
state: &mut S,
|
||||||
@ -796,6 +797,7 @@ where
|
|||||||
S: HasRand<R>,
|
S: HasRand<R>,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
|
#[allow(clippy::cast_sign_loss)]
|
||||||
fn mutate(
|
fn mutate(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut S,
|
state: &mut S,
|
||||||
@ -863,6 +865,7 @@ where
|
|||||||
S: HasRand<R>,
|
S: HasRand<R>,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
|
#[allow(clippy::cast_sign_loss)]
|
||||||
fn mutate(
|
fn mutate(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut S,
|
state: &mut S,
|
||||||
@ -1651,6 +1654,7 @@ where
|
|||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasRand<R> + HasCorpus<C, I>,
|
S: HasRand<R> + HasCorpus<C, I>,
|
||||||
{
|
{
|
||||||
|
#[allow(clippy::cast_sign_loss)]
|
||||||
fn mutate(
|
fn mutate(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut S,
|
state: &mut S,
|
||||||
@ -1670,12 +1674,12 @@ where
|
|||||||
let mut other_testcase = state.corpus().get(idx)?.borrow_mut();
|
let mut other_testcase = state.corpus().get(idx)?.borrow_mut();
|
||||||
let other = other_testcase.load_input()?;
|
let other = other_testcase.load_input()?;
|
||||||
|
|
||||||
let mut counter = 0;
|
let mut counter: u32 = 0;
|
||||||
loop {
|
loop {
|
||||||
let (f, l) = locate_diffs(input.bytes(), other.bytes());
|
let (f, l) = locate_diffs(input.bytes(), other.bytes());
|
||||||
|
|
||||||
if f != l && f >= 0 && l >= 2 {
|
if f != l && f >= 0 && l >= 2 {
|
||||||
break (f, l);
|
break (f as u64, l as u64);
|
||||||
}
|
}
|
||||||
if counter == 3 {
|
if counter == 3 {
|
||||||
return Ok(MutationResult::Skipped);
|
return Ok(MutationResult::Skipped);
|
||||||
@ -1684,9 +1688,7 @@ where
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let split_at = state
|
let split_at = state.rand_mut().between(first_diff, last_diff) as usize;
|
||||||
.rand_mut()
|
|
||||||
.between(first_diff as u64, last_diff as u64) as usize;
|
|
||||||
|
|
||||||
let mut other_testcase = state.corpus().get(idx)?.borrow_mut();
|
let mut other_testcase = state.corpus().get(idx)?.borrow_mut();
|
||||||
let other = other_testcase.load_input()?;
|
let other = other_testcase.load_input()?;
|
||||||
|
@ -9,7 +9,7 @@ use std::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
inputs::{HasBytesVec, Input},
|
inputs::{HasBytesVec, Input},
|
||||||
mutators::*,
|
mutators::{buffer_self_copy, mutations, str_decode, MutationResult, Mutator, Named},
|
||||||
state::{HasMaxSize, HasMetadata, HasRand},
|
state::{HasMaxSize, HasMetadata, HasRand},
|
||||||
utils::Rand,
|
utils::Rand,
|
||||||
Error,
|
Error,
|
||||||
@ -49,7 +49,7 @@ impl Tokens {
|
|||||||
|
|
||||||
/// Adds a token to a dictionary, checking it is not a duplicate
|
/// Adds a token to a dictionary, checking it is not a duplicate
|
||||||
/// Returns `false` if the token was already present and did not get added.
|
/// Returns `false` if the token was already present and did not get added.
|
||||||
#[allow(clippy::clippy::ptr_arg)]
|
#[allow(clippy::ptr_arg)]
|
||||||
pub fn add_token(&mut self, token: &Vec<u8>) -> bool {
|
pub fn add_token(&mut self, token: &Vec<u8>) -> bool {
|
||||||
if self.token_vec.contains(token) {
|
if self.token_vec.contains(token) {
|
||||||
return false;
|
return false;
|
||||||
@ -82,7 +82,7 @@ impl Tokens {
|
|||||||
}
|
}
|
||||||
let pos_quote = match line.find('\"') {
|
let pos_quote = match line.find('\"') {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
_ => return Err(Error::IllegalArgument("Illegal line: ".to_owned() + line)),
|
None => return Err(Error::IllegalArgument("Illegal line: ".to_owned() + line)),
|
||||||
};
|
};
|
||||||
if line.chars().nth(line.len() - 1) != Some('"') {
|
if line.chars().nth(line.len() - 1) != Some('"') {
|
||||||
return Err(Error::IllegalArgument("Illegal line: ".to_owned() + line));
|
return Err(Error::IllegalArgument("Illegal line: ".to_owned() + line));
|
||||||
@ -91,7 +91,7 @@ impl Tokens {
|
|||||||
// extract item
|
// extract item
|
||||||
let item = match line.get(pos_quote + 1..line.len() - 1) {
|
let item = match line.get(pos_quote + 1..line.len() - 1) {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
_ => return Err(Error::IllegalArgument("Illegal line: ".to_owned() + line)),
|
None => return Err(Error::IllegalArgument("Illegal line: ".to_owned() + line)),
|
||||||
};
|
};
|
||||||
if item.is_empty() {
|
if item.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
|
@ -56,6 +56,7 @@ where
|
|||||||
/// A well-known example is the AFL-Style coverage map.
|
/// A well-known example is the AFL-Style coverage map.
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
#[serde(bound = "T: serde::de::DeserializeOwned")]
|
#[serde(bound = "T: serde::de::DeserializeOwned")]
|
||||||
|
#[allow(clippy::unsafe_derive_deserialize)]
|
||||||
pub struct StdMapObserver<T>
|
pub struct StdMapObserver<T>
|
||||||
where
|
where
|
||||||
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
|
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
|
||||||
@ -156,6 +157,7 @@ where
|
|||||||
/// Overlooking a variable bitmap
|
/// Overlooking a variable bitmap
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
#[serde(bound = "T: serde::de::DeserializeOwned")]
|
#[serde(bound = "T: serde::de::DeserializeOwned")]
|
||||||
|
#[allow(clippy::unsafe_derive_deserialize)]
|
||||||
pub struct VariableMapObserver<T>
|
pub struct VariableMapObserver<T>
|
||||||
where
|
where
|
||||||
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
|
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
|
||||||
@ -226,11 +228,11 @@ where
|
|||||||
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
|
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
|
||||||
{
|
{
|
||||||
/// Creates a new MapObserver
|
/// Creates a new MapObserver
|
||||||
pub fn new(name: &'static str, map: &'static mut [T], size: &usize) -> Self {
|
pub fn new(name: &'static str, map: &'static mut [T], size: *const usize) -> Self {
|
||||||
let initial = if map.is_empty() { T::default() } else { map[0] };
|
let initial = if map.is_empty() { T::default() } else { map[0] };
|
||||||
Self {
|
Self {
|
||||||
map: ArrayMut::Cptr((map.as_mut_ptr(), map.len())),
|
map: ArrayMut::Cptr((map.as_mut_ptr(), map.len())),
|
||||||
size: Cptr::Cptr(size as *const _),
|
size: Cptr::Cptr(size),
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
initial,
|
initial,
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ impl ClientStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the calculated executions per second for this client
|
/// Get the calculated executions per second for this client
|
||||||
|
#[allow(clippy::cast_sign_loss, clippy::cast_precision_loss)]
|
||||||
pub fn execs_per_sec(&mut self, cur_time: time::Duration) -> u64 {
|
pub fn execs_per_sec(&mut self, cur_time: time::Duration) -> u64 {
|
||||||
if self.executions == 0 {
|
if self.executions == 0 {
|
||||||
return 0;
|
return 0;
|
||||||
@ -130,7 +131,7 @@ pub trait Stats {
|
|||||||
for _ in client_stat_count..(client_id + 1) as usize {
|
for _ in client_stat_count..(client_id + 1) as usize {
|
||||||
self.client_stats_mut().push(ClientStats {
|
self.client_stats_mut().push(ClientStats {
|
||||||
last_window_time: current_time(),
|
last_window_time: current_time(),
|
||||||
..Default::default()
|
..ClientStats::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
&mut self.client_stats_mut()[client_id as usize]
|
&mut self.client_stats_mut()[client_id as usize]
|
||||||
|
@ -179,7 +179,7 @@ pub struct Xoshiro256StarRand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Rand for Xoshiro256StarRand {
|
impl Rand for Xoshiro256StarRand {
|
||||||
#[allow(clippy::clippy::unreadable_literal)]
|
#[allow(clippy::unreadable_literal)]
|
||||||
fn set_seed(&mut self, seed: u64) {
|
fn set_seed(&mut self, seed: u64) {
|
||||||
self.rand_seed[0] = xxh3_64_with_seed(&HASH_CONST.to_le_bytes(), seed);
|
self.rand_seed[0] = xxh3_64_with_seed(&HASH_CONST.to_le_bytes(), seed);
|
||||||
self.rand_seed[1] = self.rand_seed[0] ^ 0x1234567890abcdef;
|
self.rand_seed[1] = self.rand_seed[0] ^ 0x1234567890abcdef;
|
||||||
@ -224,7 +224,7 @@ pub struct XorShift64Rand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Rand for XorShift64Rand {
|
impl Rand for XorShift64Rand {
|
||||||
#[allow(clippy::clippy::unreadable_literal)]
|
#[allow(clippy::unreadable_literal)]
|
||||||
fn set_seed(&mut self, seed: u64) {
|
fn set_seed(&mut self, seed: u64) {
|
||||||
self.rand_seed = seed ^ 0x1234567890abcdef;
|
self.rand_seed = seed ^ 0x1234567890abcdef;
|
||||||
}
|
}
|
||||||
@ -256,13 +256,13 @@ pub struct Lehmer64Rand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Rand for Lehmer64Rand {
|
impl Rand for Lehmer64Rand {
|
||||||
#[allow(clippy::clippy::unreadable_literal)]
|
#[allow(clippy::unreadable_literal)]
|
||||||
fn set_seed(&mut self, seed: u64) {
|
fn set_seed(&mut self, seed: u64) {
|
||||||
self.rand_seed = (seed as u128) ^ 0x1234567890abcdef;
|
self.rand_seed = u128::from(seed) ^ 0x1234567890abcdef;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::clippy::unreadable_literal)]
|
#[allow(clippy::unreadable_literal)]
|
||||||
fn next(&mut self) -> u64 {
|
fn next(&mut self) -> u64 {
|
||||||
self.rand_seed *= 0xda942042e4dd58b5;
|
self.rand_seed *= 0xda942042e4dd58b5;
|
||||||
(self.rand_seed >> 64) as u64
|
(self.rand_seed >> 64) as u64
|
||||||
@ -307,7 +307,7 @@ impl Rand for RomuTrioRand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::clippy::unreadable_literal)]
|
#[allow(clippy::unreadable_literal)]
|
||||||
fn next(&mut self) -> u64 {
|
fn next(&mut self) -> u64 {
|
||||||
let xp = self.x_state;
|
let xp = self.x_state;
|
||||||
let yp = self.y_state;
|
let yp = self.y_state;
|
||||||
@ -344,7 +344,7 @@ impl Rand for RomuDuoJrRand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::clippy::unreadable_literal)]
|
#[allow(clippy::unreadable_literal)]
|
||||||
fn next(&mut self) -> u64 {
|
fn next(&mut self) -> u64 {
|
||||||
let xp = self.x_state;
|
let xp = self.x_state;
|
||||||
self.x_state = 15241094284759029579u64.wrapping_mul(self.y_state);
|
self.x_state = 15241094284759029579u64.wrapping_mul(self.y_state);
|
||||||
|
@ -67,7 +67,7 @@ pub trait CompilerWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Wrap Clang
|
/// Wrap Clang
|
||||||
#[allow(clippy::clippy::struct_excessive_bools)]
|
#[allow(clippy::struct_excessive_bools)]
|
||||||
pub struct ClangWrapper {
|
pub struct ClangWrapper {
|
||||||
optimize: bool,
|
optimize: bool,
|
||||||
wrapped_cc: String,
|
wrapped_cc: String,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user