Skip to content

Commit

Permalink
fix bad parser
Browse files Browse the repository at this point in the history
  • Loading branch information
rmalmain committed Jan 24, 2025
1 parent 9d5c2ac commit 172d97d
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions libafl_targets/src/drcov.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,16 @@ fn parse_hex_to_u64(str: &str) -> Result<u64, ParseIntError> {
}

fn parse_path(s: &str) -> Option<PathBuf> {
let mut chars = s.trim().chars();
let s = s.trim();

// If first character is a quote, let's remove them
if chars.next()? != '\"' {

// If first char is a quote, last char must be a quote as well
if chars.next_back()? != '\"' {
log::error!("First character was a quote, but last character was not. Is path well-formed?");
return None
}

return None
}
// If first and last character is a quote, let's remove them
let s = if s.starts_with('\"') && s.ends_with('\"'){
&s[1..s.len() - 1]
} else {
s
};

Some(PathBuf::from(chars.as_str()))
Some(PathBuf::from(s))
}

impl DrCovReader {
Expand Down

0 comments on commit 172d97d

Please sign in to comment.