Skip to content

Commit

Permalink
Add regex syntax target
Browse files Browse the repository at this point in the history
Run it with `cargo run target regex_syntax`

Finds the following inputs that yield panics, some of which are also
mentioned in [1]:

- `b"(?m)?"`�
- `b"(?i)?i\x0e"`
- `b"CBh~62\x17Y((?i))??i\x0e"`�
- `b"(?m)?90"`
- `b"(?i)?"`

[1]: rust-lang/regex#465
  • Loading branch information
killercup committed Apr 27, 2018
1 parent 7987f0f commit 040c064
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ proc-macro2 = { git = "https://github.com/alexcrichton/proc-macro2.git" }
pulldown-cmark = { git = "https://github.com/google/pulldown-cmark.git" }
quick-xml = { git = "https://github.com/tafia/quick-xml" }
regex = { git = "https://github.com/rust-lang-nursery/regex" }
regex-syntax = { git = "https://github.com/rust-lang-nursery/regex" }
ring = { git = "https://github.com/briansmith/ring" }
semver = { git = "https://github.com/steveklabnik/semver" }
serde_json = { git = "https://github.com/serde-rs/json", features = ["arbitrary_precision"] }
Expand Down
8 changes: 8 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern crate proc_macro2;
extern crate pulldown_cmark;
extern crate quick_xml;
extern crate regex;
extern crate regex_syntax;
extern crate ring;
extern crate semver;
extern crate serde_json;
Expand Down Expand Up @@ -475,6 +476,13 @@ pub fn fuzz_quick_xml_read(data: &[u8]) {
}
}

#[inline(always)]
pub fn fuzz_regex_syntax(data: &[u8]) {
if let Ok(data) = std::str::from_utf8(data) {
let _ = regex_syntax::Parser::new().parse(data);
}
}

#[inline(always)]
pub fn fuzz_regex_is_match(data: &[u8]) {
if let Ok(data) = std::str::from_utf8(data) {
Expand Down

0 comments on commit 040c064

Please sign in to comment.