Update Clap (#591)

* upd

* fix
This commit is contained in:
Dongjia Zhang 2022-04-05 00:59:34 +09:00 committed by GitHub
parent 034a4870e2
commit e77e147a74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 37 deletions

View File

@ -91,7 +91,7 @@ unsafe fn fuzz(options: FuzzerOptions) -> Result<(), Error> {
(|state: Option<StdState<_, _, _, _, _>>,
mut mgr: LlmpRestartingEventManager<_, _, _, _>,
_core_id| {
let gum = unsafe { Gum::obtain() };
let gum = Gum::obtain();
let coverage = CoverageRuntime::new();
#[cfg(unix)]
@ -105,13 +105,11 @@ unsafe fn fuzz(options: FuzzerOptions) -> Result<(), Error> {
FridaInstrumentationHelper::new(&gum, &options, tuple_list!(coverage));
// Create an observation channel using the coverage map
let edges_observer = HitcountsMapObserver::new(unsafe {
StdMapObserver::new_from_ptr(
"edges",
frida_helper.map_ptr_mut().unwrap(),
MAP_SIZE,
)
});
let edges_observer = HitcountsMapObserver::new(StdMapObserver::new_from_ptr(
"edges",
frida_helper.map_ptr_mut().unwrap(),
MAP_SIZE,
));
// Create an observation channel to keep track of the execution time
let time_observer = TimeObserver::new("time");
@ -183,7 +181,7 @@ unsafe fn fuzz(options: FuzzerOptions) -> Result<(), Error> {
let observers = tuple_list!(
edges_observer,
time_observer,
AsanErrorsObserver::new(unsafe { &ASAN_ERRORS })
AsanErrorsObserver::new(&ASAN_ERRORS)
);
#[cfg(windows)]
let observers = tuple_list!(edges_observer, time_observer);
@ -221,7 +219,7 @@ unsafe fn fuzz(options: FuzzerOptions) -> Result<(), Error> {
(|state: Option<StdState<_, _, _, _, _>>,
mut mgr: LlmpRestartingEventManager<_, _, _, _>,
_core_id| {
let gum = unsafe { Gum::obtain() };
let gum = Gum::obtain();
let coverage = CoverageRuntime::new();
let cmplog = CmpLogRuntime::new();
@ -230,13 +228,11 @@ unsafe fn fuzz(options: FuzzerOptions) -> Result<(), Error> {
FridaInstrumentationHelper::new(&gum, &options, tuple_list!(coverage, cmplog));
// Create an observation channel using the coverage map
let edges_observer = HitcountsMapObserver::new(unsafe {
StdMapObserver::new_from_ptr(
"edges",
frida_helper.map_ptr_mut().unwrap(),
MAP_SIZE,
)
});
let edges_observer = HitcountsMapObserver::new(StdMapObserver::new_from_ptr(
"edges",
frida_helper.map_ptr_mut().unwrap(),
MAP_SIZE,
));
// Create an observation channel to keep track of the execution time
let time_observer = TimeObserver::new("time");
@ -301,7 +297,7 @@ unsafe fn fuzz(options: FuzzerOptions) -> Result<(), Error> {
let observers = tuple_list!(
edges_observer,
time_observer,
AsanErrorsObserver::new(unsafe { &ASAN_ERRORS })
AsanErrorsObserver::new(&ASAN_ERRORS)
);
#[cfg(windows)]
let observers = tuple_list!(edges_observer, time_observer,);
@ -330,8 +326,7 @@ unsafe fn fuzz(options: FuzzerOptions) -> Result<(), Error> {
}
// Create an observation channel using cmplog map
let cmplog_observer =
CmpLogObserver::new("cmplog", unsafe { &mut CMPLOG_MAP }, true);
let cmplog_observer = CmpLogObserver::new("cmplog", &mut CMPLOG_MAP, true);
let mut executor = ShadowExecutor::new(executor, tuple_list!(cmplog_observer));
@ -356,7 +351,7 @@ unsafe fn fuzz(options: FuzzerOptions) -> Result<(), Error> {
(|state: Option<StdState<_, _, _, _, _>>,
mut mgr: LlmpRestartingEventManager<_, _, _, _>,
_core_id| {
let gum = unsafe { Gum::obtain() };
let gum = Gum::obtain();
let coverage = CoverageRuntime::new();
@ -364,13 +359,11 @@ unsafe fn fuzz(options: FuzzerOptions) -> Result<(), Error> {
FridaInstrumentationHelper::new(&gum, &options, tuple_list!(coverage));
// Create an observation channel using the coverage map
let edges_observer = HitcountsMapObserver::new(unsafe {
StdMapObserver::new_from_ptr(
"edges",
frida_helper.map_ptr_mut().unwrap(),
MAP_SIZE,
)
});
let edges_observer = HitcountsMapObserver::new(StdMapObserver::new_from_ptr(
"edges",
frida_helper.map_ptr_mut().unwrap(),
MAP_SIZE,
));
// Create an observation channel to keep track of the execution time
let time_observer = TimeObserver::new("time");
@ -435,7 +428,7 @@ unsafe fn fuzz(options: FuzzerOptions) -> Result<(), Error> {
let observers = tuple_list!(
edges_observer,
time_observer,
AsanErrorsObserver::new(unsafe { &ASAN_ERRORS })
AsanErrorsObserver::new(&ASAN_ERRORS)
);
#[cfg(windows)]
let observers = tuple_list!(edges_observer, time_observer,);

View File

@ -63,7 +63,7 @@
//! }
//!```
use clap::{App, AppSettings, IntoApp, Parser};
use clap::{Command, CommandFactory, Parser};
use serde::{Deserialize, Serialize};
#[cfg(feature = "frida_cli")]
use std::error;
@ -105,9 +105,9 @@ fn parse_instrumentation_location(
/// Top-level container for cli options/arguments/subcommands
#[derive(Parser, Clone, Debug, Serialize, Deserialize)]
#[clap(
setting(AppSettings::ArgRequiredElseHelp),
setting(AppSettings::SubcommandPrecedenceOverArg),
setting(AppSettings::ArgsNegateSubcommands)
arg_required_else_help(true),
subcommand_precedence_over_arg(true),
args_conflicts_with_subcommands(true)
)]
#[allow(clippy::struct_excessive_bools)]
pub struct FuzzerOptions {
@ -347,9 +347,9 @@ impl FuzzerOptions {
/// }
/// ```
#[must_use]
pub fn with_subcommand(mode: App) -> App {
let app: App = Self::into_app();
app.subcommand(mode)
pub fn with_subcommand(mode: Command) -> Command {
let command: Command = Self::command();
command.subcommand(mode)
}
}

View File

@ -67,7 +67,6 @@ extern "C" {
fn __register_frame(begin: *mut c_void);
}
/// Get the current thread's TLS address
extern "C" {
fn tls_ptr() -> *const c_void;
}