From 040c064c29ea70b9645f217581807ea95cce5507 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Fri, 27 Apr 2018 13:52:54 +0200 Subject: [PATCH] Add regex syntax target 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]: https://github.com/rust-lang/regex/issues/465 --- common/Cargo.toml | 1 + common/src/lib.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/common/Cargo.toml b/common/Cargo.toml index 6d9c153..d6a326a 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -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"] } diff --git a/common/src/lib.rs b/common/src/lib.rs index 9af3a22..6bb204d 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -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; @@ -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) {