diff --git a/fuzzers/frida_gdiplus/src/fuzzer.rs b/fuzzers/frida_gdiplus/src/fuzzer.rs index dca5e5af98..a9f65693ae 100644 --- a/fuzzers/frida_gdiplus/src/fuzzer.rs +++ b/fuzzers/frida_gdiplus/src/fuzzer.rs @@ -102,10 +102,10 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> { #[cfg(unix)] let mut frida_helper = - FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage, asan))?; + FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage, asan)); #[cfg(windows)] let mut frida_helper = - FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage))?; + FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage)); // Create an observation channel using the coverage map let edges_observer = HitcountsMapObserver::new(StdMapObserver::from_mut_ptr( @@ -221,7 +221,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> { let cmplog = CmpLogRuntime::new(); let mut frida_helper = - FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage, cmplog))?; + FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage, cmplog)); // Create an observation channel using the coverage map let edges_observer = HitcountsMapObserver::new(StdMapObserver::from_mut_ptr( @@ -351,7 +351,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> { let coverage = CoverageRuntime::new(); let mut frida_helper = - FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage))?; + FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage)); // Create an observation channel using the coverage map let edges_observer = HitcountsMapObserver::new(StdMapObserver::from_mut_ptr( diff --git a/fuzzers/frida_libpng/src/fuzzer.rs b/fuzzers/frida_libpng/src/fuzzer.rs index 16cb567f03..bd862c3b03 100644 --- a/fuzzers/frida_libpng/src/fuzzer.rs +++ b/fuzzers/frida_libpng/src/fuzzer.rs @@ -99,10 +99,10 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> { #[cfg(unix)] let mut frida_helper = - FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage, asan))?; + FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage, asan)); #[cfg(windows)] let mut frida_helper = - FridaInstrumentationHelper::new(&gum, &options, tuple_list!(coverage))?; + FridaInstrumentationHelper::new(&gum, &options, tuple_list!(coverage)); // Create an observation channel using the coverage map let edges_observer = HitcountsMapObserver::new(StdMapObserver::from_mut_ptr( @@ -219,7 +219,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> { let cmplog = CmpLogRuntime::new(); let mut frida_helper = - FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage, cmplog))?; + FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage, cmplog)); // Create an observation channel using the coverage map let edges_observer = HitcountsMapObserver::new(StdMapObserver::from_mut_ptr( @@ -349,7 +349,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> { let coverage = CoverageRuntime::new(); let mut frida_helper = - FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage))?; + FridaInstrumentationHelper::new(&gum, options, tuple_list!(coverage)); // Create an observation channel using the coverage map let edges_observer = HitcountsMapObserver::new(StdMapObserver::from_mut_ptr( diff --git a/libafl_frida/src/helper.rs b/libafl_frida/src/helper.rs index b5dbd90518..6c118d1721 100644 --- a/libafl_frida/src/helper.rs +++ b/libafl_frida/src/helper.rs @@ -165,7 +165,8 @@ where { /// Constructor function to create a new [`FridaInstrumentationHelper`], given a `module_name`. #[allow(clippy::too_many_lines)] - pub fn new(gum: &'a Gum, options: &'a FuzzerOptions, runtimes: RT) -> Result { + #[must_use] + pub fn new(gum: &'a Gum, options: &'a FuzzerOptions, runtimes: RT) -> Self { // workaround frida's frida-gum-allocate-near bug: #[cfg(unix)] unsafe { @@ -178,8 +179,7 @@ where -1, 0, ) - .map_err(|_| Error::unknown("Failed to map dummy regions for frida workaround"))?; - + .expect("Failed to map dummy regions for frida workaround"); mmap( None, std::num::NonZeroUsize::new_unchecked(4 * 1024 * 1024), @@ -188,14 +188,14 @@ where -1, 0, ) - .map_err(|_| Error::unknown("Failed to map dummy regions for frida workaround"))?; + .expect("Failed to map dummy regions for frida workaround"); } } let mut modules_to_instrument = vec![options .harness .as_ref() - .ok_or_else(|| Error::unknown("No modueles to instrument"))? + .unwrap() .to_string_lossy() .to_string()]; modules_to_instrument.append(&mut options.libs_to_instrument.clone()); @@ -209,14 +209,14 @@ where .mode(arch::arm64::ArchMode::Arm) .detail(true) .build() - .map_err(|_| Error::unknown("Failed to create Capstone object"))?, + .expect("Failed to create Capstone object"), #[cfg(all(target_arch = "x86_64", unix))] capstone: Capstone::new() .x86() .mode(arch::x86::ArchMode::Mode64) .detail(true) .build() - .map_err(|_| Error::unknown("Failed to create Capstone object"))?, + .expect("Failed to create Capstone object"), ranges: RangeMap::new(), module_map: ModuleMap::new_from_names(gum, &modules_to_instrument), options, @@ -235,8 +235,7 @@ where } if !options.dont_instrument.is_empty() { for (module_name, offset) in options.dont_instrument.clone() { - let module_details = ModuleDetails::with_name(module_name.clone()) - .ok_or_else(|| Error::unknown("Module {module_name} not found"))?; + let module_details = ModuleDetails::with_name(module_name).unwrap(); let lib_start = module_details.range().base_address().0 as usize; // println!("removing address: {:#x}", lib_start + offset); helper @@ -366,7 +365,7 @@ where helper.transformer = Some(transformer); - Ok(helper) + helper } /// Return the runtime