Skip to content

Commit

Permalink
Add param parsing fuzzer and fix finding
Browse files Browse the repository at this point in the history
Closes #55
  • Loading branch information
stusmall authored and mcginty committed Jun 22, 2019
1 parent f1c5d53 commit 1e7ade0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 15 additions & 0 deletions hfuzz/src/bin/params.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#[macro_use] extern crate honggfuzz;
extern crate snow;

fn main() {
loop {
fuzz!(|data: &[u8]| {
if let Ok(s) = String::from_utf8(data.to_vec()){
if let Ok(p) = s.parse(){
let builder = snow::Builder::new(p);
let _ = builder.build_initiator();
}
}
});
}
}
6 changes: 4 additions & 2 deletions src/params/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ impl HandshakeChoice {
fn parse_pattern_and_modifier(s: &str) -> Result<(HandshakePattern, &str), Error> {
for i in (1..=4).rev() {
if s.len() > i-1 {
if let Ok(p) = (&s[..i]).parse() {
return Ok((p, &s[i..]));
if s.is_char_boundary(i) {
if let Ok(p) = (&s[..i]).parse() {
return Ok((p, &s[i..]));
}
}
}
}
Expand Down

0 comments on commit 1e7ade0

Please sign in to comment.