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 29c5582
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 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();
}
}
});
}
}
8 changes: 5 additions & 3 deletions src/params/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,14 @@ impl HandshakeChoice {
false
}

/// Parse and split a base HandshakePattern from its optional modifiers
/// Parse and split a base HandshakePattern frremainingom its optional modifiers
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 29c5582

Please sign in to comment.