Clippy fixes for frida_executable_libpng fuzzer (#1438)

This commit is contained in:
Dominik Maier 2023-08-21 19:41:03 +02:00 committed by GitHub
parent a426b6fc3d
commit 6e5d102673
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -54,15 +54,15 @@ pub unsafe fn lib(main: extern "C" fn(i32, *const *const u8, *const *const u8) -
let options = parse_args();
let mut frida_harness = |input: &BytesInput| {
let frida_harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
let len = buf.len().to_string();
let argv: [*const u8; 3] = [
null(), // dummy value
len.as_ptr() as _,
buf.as_ptr() as _,
len.as_ptr().cast(),
buf.as_ptr().cast(),
];
let env: [*const u8; 2] = [
@ -75,7 +75,7 @@ pub unsafe fn lib(main: extern "C" fn(i32, *const *const u8, *const *const u8) -
};
unsafe {
match fuzz(&options, &mut frida_harness) {
match fuzz(&options, &frida_harness) {
Ok(()) | Err(Error::ShuttingDown) => println!("\nFinished fuzzing. Good bye."),
Err(e) => panic!("Error during fuzzing: {e:?}"),
}

View File

@ -1,3 +1,4 @@
#![allow(clippy::missing_safety_doc)]
use std::mem::transmute;
use libc::{c_void, dlsym, RTLD_NEXT};
@ -33,6 +34,7 @@ pub unsafe extern "C" fn main_hook(
}
#[no_mangle]
#[allow(clippy::similar_names)]
pub unsafe extern "C" fn __libc_start_main(
main: extern "C" fn(i32, *const *const u8, *const *const u8) -> i32,
argc: i32,
@ -46,13 +48,10 @@ pub unsafe extern "C" fn __libc_start_main(
ORIG_MAIN = main;
let orig_libc_start_main_addr: *mut c_void =
dlsym(RTLD_NEXT, "__libc_start_main\0".as_ptr() as *const i8);
dlsym(RTLD_NEXT, "__libc_start_main\0".as_ptr().cast::<i8>());
let orig_libc_start_main: LibcStartMainFunc = transmute(orig_libc_start_main_addr);
let exit_code =
orig_libc_start_main(main_hook, argc, argv, init, fini, rtld_fini, stack_end);
return exit_code;
orig_libc_start_main(main_hook, argc, argv, init, fini, rtld_fini, stack_end)
}
}