aboutsummaryrefslogtreecommitdiff
path: root/tests/regression_fuzz.rs
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-05-19 16:51:51 -0700
committerJoel Galenson <jgalenson@google.com>2021-05-19 16:51:51 -0700
commit3874808a33005b78d4dcbc84fc41afe856c2904c (patch)
tree02c0b3035a3cf71f10f04c344fb3e636a1090409 /tests/regression_fuzz.rs
parentffb6030a530f824e597fae242b0c77c0743fc545 (diff)
downloadregex-3874808a33005b78d4dcbc84fc41afe856c2904c.tar.gz
Upgrade rust/crates/regex to 1.5.4
Test: make Change-Id: I0eab39246dc2aea41a62c15661e350b490f06c1d
Diffstat (limited to 'tests/regression_fuzz.rs')
-rw-r--r--tests/regression_fuzz.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/regression_fuzz.rs b/tests/regression_fuzz.rs
index 5f92ed0..4e76704 100644
--- a/tests/regression_fuzz.rs
+++ b/tests/regression_fuzz.rs
@@ -17,3 +17,15 @@ fn fuzz1() {
fn empty_any_errors_no_panic() {
assert!(regex_new!(r"\P{any}").is_err());
}
+
+// This tests that a very large regex errors during compilation instead of
+// using gratuitous amounts of memory. The specific problem is that the
+// compiler wasn't accounting for the memory used by Unicode character classes
+// correctly.
+//
+// See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33579
+#[test]
+fn big_regex_fails_to_compile() {
+ let pat = "[\u{0}\u{e}\u{2}\\w~~>[l\t\u{0}]p?<]{971158}";
+ assert!(regex_new!(pat).is_err());
+}