[llvm] r316537 - Check special-case-list regex before insertion.
Mitch Phillips via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 24 16:56:13 PDT 2017
Author: hctim
Date: Tue Oct 24 16:56:12 2017
New Revision: 316537
URL: http://llvm.org/viewvc/llvm-project?rev=316537&view=rev
Log:
Check special-case-list regex before insertion.
Summary:
Checks that the supplied regex to SpecialCaseList::Matcher::insert(..) is non-empty.
Reported by OSS-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3688
Verified that this fixes the provided assertion failure (built with {asan, fuzzer}):
```
mitchp at mitchp2:~/llvm-build/git-fuzz$ ninja llvm-special-case-list-fuzzer[12/12] Linking CXX executable bin/llvm-special-case-list-fuzzer
mitchp at mitchp2:~/llvm-build/git-fuzz$ bin/llvm-special-case-list-fuzzer ~/Downloads/clusterfuzz-testcase-6748633157337088
INFO: Seed: 1697404507
INFO: Loaded 1 modules (18581 inline 8-bit counters): 18581 [0x9e9f60, 0x9ee7f5),
INFO: Loaded 1 PC tables (18581 PCs): 18581 [0x9ee7f8,0xa37148),
bin/llvm-special-case-list-fuzzer: Running 1 inputs 1 time(s) each.
Running: /usr/local/google/home/mitchp/Downloads/clusterfuzz-testcase-6748633157337088
Executed /usr/local/google/home/mitchp/Downloads/clusterfuzz-testcase-6748633157337088 in 0 ms
***
*** NOTE: fuzzing was not performed, you have only
*** executed the target code on a fixed set of inputs.
***
mitchp at mitchp2:~/llvm-build/git-fuzz$
```
Reviewers: kcc, vsk
Reviewed By: vsk
Subscribers: vsk, llvm-commits, vlad.tsyrklevich
Differential Revision: https://reviews.llvm.org/D39212
Modified:
llvm/trunk/lib/Support/SpecialCaseList.cpp
llvm/trunk/unittests/Support/SpecialCaseListTest.cpp
Modified: llvm/trunk/lib/Support/SpecialCaseList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SpecialCaseList.cpp?rev=316537&r1=316536&r2=316537&view=diff
==============================================================================
--- llvm/trunk/lib/Support/SpecialCaseList.cpp (original)
+++ llvm/trunk/lib/Support/SpecialCaseList.cpp Tue Oct 24 16:56:12 2017
@@ -28,6 +28,11 @@ namespace llvm {
bool SpecialCaseList::Matcher::insert(std::string Regexp,
std::string &REError) {
+ if (Regexp.empty()) {
+ REError = "Supplied regexp was blank";
+ return false;
+ }
+
if (Regex::isLiteralERE(Regexp)) {
Strings.insert(Regexp);
return true;
Modified: llvm/trunk/unittests/Support/SpecialCaseListTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/SpecialCaseListTest.cpp?rev=316537&r1=316536&r2=316537&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/SpecialCaseListTest.cpp (original)
+++ llvm/trunk/unittests/Support/SpecialCaseListTest.cpp Tue Oct 24 16:56:12 2017
@@ -67,6 +67,9 @@ TEST_F(SpecialCaseListTest, SectionRegex
EXPECT_EQ(makeSpecialCaseList("[[]", Error), nullptr);
EXPECT_TRUE(((StringRef)Error).startswith("malformed regex for section [: "));
+
+ EXPECT_EQ(makeSpecialCaseList("src:=", Error), nullptr);
+ EXPECT_TRUE(((StringRef)Error).endswith("Supplied regexp was blank"));
}
TEST_F(SpecialCaseListTest, Section) {
More information about the llvm-commits
mailing list