Disable QemuInjectionHelper if not configured (#1804)

Co-authored-by: Your Name <you@example.com>
This commit is contained in:
WorksButNotTested 2024-01-18 17:53:42 +00:00 committed by GitHub
parent df8fa71aa7
commit e615cb4aed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -126,27 +126,25 @@ impl<'a> Client<'a> {
log::debug!("start_pc @ {start_pc:#x}"); log::debug!("start_pc @ {start_pc:#x}");
#[cfg(not(feature = "injections"))] #[cfg(not(feature = "injections"))]
let extra_tokens = None; let injection_helper = None;
#[cfg(feature = "injections")] #[cfg(feature = "injections")]
let injection_helper = self let injection_helper = self
.options .options
.injections .injections
.as_ref() .as_ref()
.map(|injections_file| { .and_then(|injections_file| {
let lower = injections_file.to_lowercase(); let lower = injections_file.to_lowercase();
if lower.ends_with("yaml") || lower.ends_with("yml") { if lower.ends_with("yaml") || lower.ends_with("yml") {
QemuInjectionHelper::from_yaml(injections_file) Some(QemuInjectionHelper::from_yaml(injections_file).unwrap())
} else if lower.ends_with("toml") { } else if lower.ends_with("toml") {
QemuInjectionHelper::from_toml(injections_file) Some(QemuInjectionHelper::from_toml(injections_file).unwrap())
} else { } else {
todo!("No injections given, what to do?"); None
} }
}) });
.unwrap()
.unwrap(); let extra_tokens = injection_helper.as_ref().map(|h| h.tokens.clone());
#[cfg(feature = "injections")]
let extra_tokens = Some(injection_helper.tokens.clone());
emu.entry_break(start_pc); emu.entry_break(start_pc);
@ -167,50 +165,71 @@ impl<'a> Client<'a> {
.mgr(mgr) .mgr(mgr)
.core_id(core_id) .core_id(core_id)
.extra_tokens(extra_tokens); .extra_tokens(extra_tokens);
if is_asan && is_cmplog { if is_asan && is_cmplog {
#[cfg(not(feature = "injections"))] if let Some(injection_helper) = injection_helper {
let helpers = tuple_list!( instance.build().run(
edge_coverage_helper, tuple_list!(
QemuCmpLogHelper::default(), edge_coverage_helper,
QemuAsanHelper::default(asan.take().unwrap()), QemuCmpLogHelper::default(),
); QemuAsanHelper::default(asan.take().unwrap()),
#[cfg(feature = "injections")] injection_helper,
let helpers = tuple_list!( ),
edge_coverage_helper, state,
QemuCmpLogHelper::default(), )
QemuAsanHelper::default(asan.take().unwrap()), } else {
injection_helper, instance.build().run(
); tuple_list!(
instance.build().run(helpers, state) edge_coverage_helper,
QemuCmpLogHelper::default(),
QemuAsanHelper::default(asan.take().unwrap()),
),
state,
)
}
} else if is_asan { } else if is_asan {
#[cfg(not(feature = "injections"))] if let Some(injection_helper) = injection_helper {
let helpers = tuple_list!( instance.build().run(
edge_coverage_helper, tuple_list!(
QemuAsanHelper::default(asan.take().unwrap()), edge_coverage_helper,
); QemuAsanHelper::default(asan.take().unwrap()),
#[cfg(feature = "injections")] injection_helper
let helpers = tuple_list!( ),
edge_coverage_helper, state,
QemuAsanHelper::default(asan.take().unwrap()), )
injection_helper, } else {
); instance.build().run(
instance.build().run(helpers, state) tuple_list!(
edge_coverage_helper,
QemuAsanHelper::default(asan.take().unwrap()),
),
state,
)
}
} else if is_cmplog { } else if is_cmplog {
#[cfg(not(feature = "injections"))] if let Some(injection_helper) = injection_helper {
let helpers = tuple_list!(edge_coverage_helper, QemuCmpLogHelper::default(),); instance.build().run(
#[cfg(feature = "injections")] tuple_list!(
let helpers = tuple_list!( edge_coverage_helper,
edge_coverage_helper, QemuCmpLogHelper::default(),
QemuCmpLogHelper::default(), injection_helper
injection_helper, ),
); state,
instance.build().run(helpers, state) )
} else {
instance.build().run(
tuple_list!(edge_coverage_helper, QemuCmpLogHelper::default()),
state,
)
}
} else if let Some(injection_helper) = injection_helper {
instance
.build()
.run(tuple_list!(edge_coverage_helper, injection_helper), state)
} else { } else {
#[cfg(not(feature = "injections"))] instance
let helpers = tuple_list!(edge_coverage_helper,); .build()
#[cfg(feature = "injections")] .run(tuple_list!(edge_coverage_helper), state)
let helpers = tuple_list!(edge_coverage_helper, injection_helper,);
instance.build().run(helpers, state)
} }
} }
} }