Skip to content

Commit

Permalink
Add param parsing fuzzer and fix finding
Browse files Browse the repository at this point in the history
  • Loading branch information
stusmall committed May 11, 2019
1 parent 64dbb97 commit 800b85c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions hfuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
authors = ["Jake McGinty <[email protected]>"]

[dependencies]
honggfuzz = { git = "https://github.com/mcginty/honggfuzz-rs", branch = "assert-unwind" }
honggfuzz = "0.5"
snow = { path = "../" }
lazy_static = "*"
lazy_static = "*"
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 800b85c

Please sign in to comment.