qemu_launcher: Fix command line parsing of ranges (#2804)
Co-authored-by: Your Name <you@example.com> Co-authored-by: Dominik Maier <domenukk@gmail.com>
This commit is contained in:
parent
d39ded5b29
commit
da55e70aa3
@ -92,33 +92,23 @@ impl FuzzerOptions {
|
||||
Ok(Duration::from_millis(src.parse()?))
|
||||
}
|
||||
|
||||
fn parse_ranges(src: &str) -> Result<Vec<Range<GuestAddr>>, Error> {
|
||||
src.split(',')
|
||||
.map(|r| {
|
||||
let parts = r.split('-').collect::<Vec<&str>>();
|
||||
fn parse_ranges(src: &str) -> Result<Range<GuestAddr>, Error> {
|
||||
let parts = src.split('-').collect::<Vec<&str>>();
|
||||
if parts.len() == 2 {
|
||||
let start = GuestAddr::from_str_radix(parts[0].trim_start_matches("0x"), 16)
|
||||
.map_err(|e| {
|
||||
Error::illegal_argument(format!(
|
||||
"Invalid start address: {} ({e:})",
|
||||
parts[0]
|
||||
))
|
||||
let start =
|
||||
GuestAddr::from_str_radix(parts[0].trim_start_matches("0x"), 16).map_err(|e| {
|
||||
Error::illegal_argument(format!("Invalid start address: {} ({e:})", parts[0]))
|
||||
})?;
|
||||
let end = GuestAddr::from_str_radix(parts[1].trim_start_matches("0x"), 16)
|
||||
.map_err(|e| {
|
||||
Error::illegal_argument(format!(
|
||||
"Invalid end address: {} ({e:})",
|
||||
parts[1]
|
||||
))
|
||||
let end =
|
||||
GuestAddr::from_str_radix(parts[1].trim_start_matches("0x"), 16).map_err(|e| {
|
||||
Error::illegal_argument(format!("Invalid end address: {} ({e:})", parts[1]))
|
||||
})?;
|
||||
Ok(Range { start, end })
|
||||
} else {
|
||||
Err(Error::illegal_argument(format!(
|
||||
"Invalid range provided: {r:}"
|
||||
"Invalid range provided: {src:}"
|
||||
)))
|
||||
}
|
||||
})
|
||||
.collect::<Result<Vec<Range<GuestAddr>>, Error>>()
|
||||
}
|
||||
|
||||
pub fn is_asan_core(&self, core_id: CoreId) -> bool {
|
||||
|
Loading…
x
Reference in New Issue
Block a user