New year new clippy (#2797)

* New year new clippy

* More clipy

* fix
This commit is contained in:
Dominik Maier 2025-01-01 20:57:43 +01:00 committed by GitHub
parent 92db678995
commit deb76555b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 30 additions and 29 deletions

View File

@ -175,7 +175,7 @@ pub trait Corpus: Sized {
fn nth(&self, nth: usize) -> CorpusId { fn nth(&self, nth: usize) -> CorpusId {
self.ids() self.ids()
.nth(nth) .nth(nth)
.expect("Failed to get the {nth} CorpusId") .unwrap_or_else(|| panic!("Failed to get the {nth} CorpusId"))
} }
/// Get the nth corpus id; considers both enabled and disabled testcases /// Get the nth corpus id; considers both enabled and disabled testcases

View File

@ -417,7 +417,7 @@ where
+ EvaluatorObservers<E, Self, <S::Corpus as Corpus>::Input, S> + EvaluatorObservers<E, Self, <S::Corpus as Corpus>::Input, S>
+ Evaluator<E, Self, <S::Corpus as Corpus>::Input, S>, + Evaluator<E, Self, <S::Corpus as Corpus>::Input, S>,
{ {
println!("Got event in client: {} from {:?}", event.name(), client_id); log::trace!("Got event in client: {} from {client_id:?}", event.name());
if !self.hooks.pre_exec_all(state, client_id, &event)? { if !self.hooks.pre_exec_all(state, client_id, &event)? {
return Ok(()); return Ok(());
} }
@ -565,7 +565,7 @@ where
#[cfg(not(feature = "llmp_compression"))] #[cfg(not(feature = "llmp_compression"))]
{ {
self.llmp self.llmp
.send_buf(LLMP_TAG_EVENT_TO_BOTH, &self.event_buffer[..written_len]); .send_buf(LLMP_TAG_EVENT_TO_BOTH, &self.event_buffer[..written_len])?;
} }
self.last_sent = current_time(); self.last_sent = current_time();

View File

@ -353,7 +353,7 @@ impl<I, S> MutatorsTuple<I, S> for Vec<Box<dyn Mutator<I, S>>> {
) -> Result<MutationResult, Error> { ) -> Result<MutationResult, Error> {
let mutator = self let mutator = self
.get_mut(index.0) .get_mut(index.0)
.ok_or_else(|| Error::key_not_found("Mutator with id {index:?} not found."))?; .ok_or_else(|| Error::key_not_found(format!("Mutator with id {index:?} not found.")))?;
mutator.mutate(state, input) mutator.mutate(state, input)
} }
@ -365,7 +365,7 @@ impl<I, S> MutatorsTuple<I, S> for Vec<Box<dyn Mutator<I, S>>> {
) -> Result<(), Error> { ) -> Result<(), Error> {
let mutator = self let mutator = self
.get_mut(index) .get_mut(index)
.ok_or_else(|| Error::key_not_found("Mutator with id {index:?} not found."))?; .ok_or_else(|| Error::key_not_found(format!("Mutator with id {index:?} not found.")))?;
mutator.post_exec(state, new_corpus_id) mutator.post_exec(state, new_corpus_id)
} }
} }

View File

@ -1059,7 +1059,7 @@ impl AFLppRedQueen {
if buf_16 == pattern as u16 && another_buf_16 == another_pattern as u16 { if buf_16 == pattern as u16 && another_buf_16 == another_pattern as u16 {
let mut cloned = buf.to_vec(); let mut cloned = buf.to_vec();
cloned[buf_idx + 1] = (repl & 0xff) as u8; cloned[buf_idx + 1] = (repl & 0xff) as u8;
cloned[buf_idx] = (repl >> 8 & 0xff) as u8; cloned[buf_idx] = ((repl >> 8) & 0xff) as u8;
vec.push(cloned); vec.push(cloned);
return Ok(true); return Ok(true);
} }
@ -1074,9 +1074,9 @@ impl AFLppRedQueen {
if buf_32 == pattern as u32 && another_buf_32 == another_pattern as u32 { if buf_32 == pattern as u32 && another_buf_32 == another_pattern as u32 {
let mut cloned = buf.to_vec(); let mut cloned = buf.to_vec();
cloned[buf_idx + 3] = (repl & 0xff) as u8; cloned[buf_idx + 3] = (repl & 0xff) as u8;
cloned[buf_idx + 2] = (repl >> 8 & 0xff) as u8; cloned[buf_idx + 2] = ((repl >> 8) & 0xff) as u8;
cloned[buf_idx + 1] = (repl >> 16 & 0xff) as u8; cloned[buf_idx + 1] = ((repl >> 16) & 0xff) as u8;
cloned[buf_idx] = (repl >> 24 & 0xff) as u8; cloned[buf_idx] = ((repl >> 24) & 0xff) as u8;
vec.push(cloned); vec.push(cloned);
return Ok(true); return Ok(true);
@ -1093,13 +1093,13 @@ impl AFLppRedQueen {
let mut cloned = buf.to_vec(); let mut cloned = buf.to_vec();
cloned[buf_idx + 7] = (repl & 0xff) as u8; cloned[buf_idx + 7] = (repl & 0xff) as u8;
cloned[buf_idx + 6] = (repl >> 8 & 0xff) as u8; cloned[buf_idx + 6] = ((repl >> 8) & 0xff) as u8;
cloned[buf_idx + 5] = (repl >> 16 & 0xff) as u8; cloned[buf_idx + 5] = ((repl >> 16) & 0xff) as u8;
cloned[buf_idx + 4] = (repl >> 24 & 0xff) as u8; cloned[buf_idx + 4] = ((repl >> 24) & 0xff) as u8;
cloned[buf_idx + 3] = (repl >> 32 & 0xff) as u8; cloned[buf_idx + 3] = ((repl >> 32) & 0xff) as u8;
cloned[buf_idx + 2] = (repl >> 32 & 0xff) as u8; cloned[buf_idx + 2] = ((repl >> 32) & 0xff) as u8;
cloned[buf_idx + 1] = (repl >> 40 & 0xff) as u8; cloned[buf_idx + 1] = ((repl >> 40) & 0xff) as u8;
cloned[buf_idx] = (repl >> 48 & 0xff) as u8; cloned[buf_idx] = ((repl >> 48) & 0xff) as u8;
vec.push(cloned); vec.push(cloned);
return Ok(true); return Ok(true);

View File

@ -239,9 +239,10 @@ impl FridaInstrumentationHelperBuilder {
let name = path let name = path
.file_name() .file_name()
.and_then(|name| name.to_str()) .and_then(|name| name.to_str())
.expect("Failed to get script file name from path: {path:}"); .unwrap_or_else(|| panic!("Failed to get script file name from path: {path:?}"));
let script_prefix = include_str!("script.js"); let script_prefix = include_str!("script.js");
let file_contents = read_to_string(path).expect("Failed to read script: {path:}"); let file_contents = read_to_string(path)
.unwrap_or_else(|err| panic!("Failed to read script {path:?}: {err:?}"));
let payload = script_prefix.to_string() + &file_contents; let payload = script_prefix.to_string() + &file_contents;
let gum = Gum::obtain(); let gum = Gum::obtain();
let backend = match backend { let backend = match backend {

View File

@ -182,13 +182,13 @@ where
.push(Box::pin((InstructionHookId::invalid(), fat))); .push(Box::pin((InstructionHookId::invalid(), fat)));
unsafe { unsafe {
let hook_state = &mut self let hook_state = &raw mut self
.instruction_hooks .instruction_hooks
.last_mut() .last_mut()
.unwrap() .unwrap()
.as_mut() .as_mut()
.get_unchecked_mut() .get_unchecked_mut()
.1 as *mut FatPtr; .1;
let id = self.qemu_hooks.add_instruction_hooks( let id = self.qemu_hooks.add_instruction_hooks(
&mut *hook_state, &mut *hook_state,
@ -656,13 +656,13 @@ where
self.backdoor_hooks self.backdoor_hooks
.push(Box::pin((BackdoorHookId::invalid(), fat))); .push(Box::pin((BackdoorHookId::invalid(), fat)));
let hook_state = &mut self let hook_state = &raw mut self
.backdoor_hooks .backdoor_hooks
.last_mut() .last_mut()
.unwrap() .unwrap()
.as_mut() .as_mut()
.get_unchecked_mut() .get_unchecked_mut()
.1 as *mut FatPtr; .1;
let id = self let id = self
.qemu_hooks .qemu_hooks
@ -739,13 +739,13 @@ where
self.new_thread_hooks self.new_thread_hooks
.push(Box::pin((NewThreadHookId::invalid(), fat))); .push(Box::pin((NewThreadHookId::invalid(), fat)));
let hook_state = &mut self let hook_state = &raw mut self
.new_thread_hooks .new_thread_hooks
.last_mut() .last_mut()
.unwrap() .unwrap()
.as_mut() .as_mut()
.get_unchecked_mut() .get_unchecked_mut()
.1 as *mut FatPtr; .1;
let id = self let id = self
.qemu_hooks .qemu_hooks
@ -797,13 +797,13 @@ where
self.pre_syscall_hooks self.pre_syscall_hooks
.push(Box::pin((PreSyscallHookId::invalid(), fat))); .push(Box::pin((PreSyscallHookId::invalid(), fat)));
let hook_state = &mut self let hook_state = &raw mut self
.pre_syscall_hooks .pre_syscall_hooks
.last_mut() .last_mut()
.unwrap() .unwrap()
.as_mut() .as_mut()
.get_unchecked_mut() .get_unchecked_mut()
.1 as *mut FatPtr; .1;
let id = self let id = self
.qemu_hooks .qemu_hooks
@ -848,13 +848,13 @@ where
self.post_syscall_hooks self.post_syscall_hooks
.push(Box::pin((PostSyscallHookId::invalid(), fat))); .push(Box::pin((PostSyscallHookId::invalid(), fat)));
let hooks_state = &mut self let hooks_state = &raw mut self
.post_syscall_hooks .post_syscall_hooks
.last_mut() .last_mut()
.unwrap() .unwrap()
.as_mut() .as_mut()
.get_unchecked_mut() .get_unchecked_mut()
.1 as *mut FatPtr; .1;
let id = self.qemu_hooks.add_post_syscall_hook( let id = self.qemu_hooks.add_post_syscall_hook(
&mut *hooks_state, &mut *hooks_state,

View File

@ -286,7 +286,7 @@ pub mod pybind {
a6: u64, a6: u64,
a7: u64, a7: u64,
) -> SyscallHookResult { ) -> SyscallHookResult {
unsafe { PY_SYSCALL_HOOK.as_ref() }.map_or_else( unsafe { &*(&raw const PY_SYSCALL_HOOK).as_ref() }.map_or_else(
|| SyscallHookResult::new(None), || SyscallHookResult::new(None),
|obj| { |obj| {
let args = (sys_num, a0, a1, a2, a3, a4, a5, a6, a7); let args = (sys_num, a0, a1, a2, a3, a4, a5, a6, a7);