aboutsummaryrefslogtreecommitdiff
path: root/re2/testing/re2_test.cc
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2014-12-18 15:43:21 -0500
committerRuss Cox <rsc@swtch.com>2014-12-18 20:46:16 +0000
commitbdb5058dcf7a3e6e8fe524a6214d5a7a6e9dcba2 (patch)
treedf0f8ba8c0b4d474243b44613f45d29188a2703a /re2/testing/re2_test.cc
parent499ef7eff7455ce9c9fae86111d4a77b6ac335de (diff)
downloadregex-re2-bdb5058dcf7a3e6e8fe524a6214d5a7a6e9dcba2.tar.gz
re2: three minor bug fixes
Found during testing inside Google. Change-Id: I93f824fd828b93b214c62b69b93d58f841b83bf1 Reviewed-on: https://code-review.googlesource.com/1593 Reviewed-by: Russ Cox <rsc@swtch.com>
Diffstat (limited to 're2/testing/re2_test.cc')
-rw-r--r--re2/testing/re2_test.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc
index 0598f85..d80f313 100644
--- a/re2/testing/re2_test.cc
+++ b/re2/testing/re2_test.cc
@@ -1430,4 +1430,49 @@ TEST(RE2, Bug10131674) {
EXPECT_FALSE(RE2::FullMatch("hello world", re));
}
+TEST(RE2, Bug18391750) {
+ // Stray write past end of match_ in nfa.cc, caught by fuzzing + address sanitizer.
+ char t[] = {0x28, 0x28, 0xfc, 0xfc, 0x8, 0x8, 0x26, 0x26, 0x28, 0xc2, 0x9b,
+ 0xc5, 0xc5, 0xd4, 0x8f, 0x8f, 0x69, 0x69, 0xe7, 0x29, 0x7b, 0x37,
+ 0x31, 0x31, 0x7d, 0xae, 0x7c, 0x7c, 0xf3, 0x29, 0xae, 0xae, 0x2e,
+ 0x2a, 0x29, 0x0};
+ RE2::Options opt;
+ opt.set_encoding(RE2::Options::EncodingLatin1);
+ opt.set_longest_match(true);
+ opt.set_dot_nl(true);
+ opt.set_case_sensitive(false);
+ RE2 re(t, opt);
+ CHECK(re.ok());
+ RE2::PartialMatch(t, re);
+}
+
+TEST(RE2, Bug18458852) {
+ // Bug in parser accepting invalid (too large) rune,
+ // causing compiler to fail in DCHECK in UTF-8
+ // character class code.
+ char b[] = {0x28, 0x5, 0x5, 0x41, 0x41, 0x28, 0x24, 0x5b, 0x5e,
+ 0xf5, 0x87, 0x87, 0x90, 0x29, 0x5d, 0x29, 0x29, 0x0};
+ RE2 re(b);
+ CHECK(!re.ok());
+}
+
+TEST(RE2, Bug18523943) {
+ // Bug in bitstate: case kFailInst was merged into the default with LOG(DFATAL).
+
+ RE2::Options opt;
+ char a[] = {0x29, 0x29, 0x24, 0x0};
+ char b[] = {0x28, 0xa, 0x2a, 0x2a, 0x29, 0x0};
+ opt.set_log_errors(false);
+ opt.set_encoding(RE2::Options::EncodingLatin1);
+ opt.set_posix_syntax(true);
+ opt.set_longest_match(true);
+ opt.set_literal(false);
+ opt.set_never_nl(true);
+
+ RE2 re((const char*)b, opt);
+ CHECK(re.ok());
+ string s1;
+ CHECK(!RE2::PartialMatch((const char*)a, re, &s1));
+}
+
} // namespace re2