Skip to content

Commit fd8e72f

Browse files
victorhoraFelipe Zimmerle
authored andcommitted
Allow empty strings to be evaluated by regex::searchAll
1 parent 7def498 commit fd8e72f

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ LOG_COMPILER=test/test-suite.sh
8787
# for i in `find test/test-cases -iname *.json`; do echo TESTS+=$i; done
8888
TESTS=
8989
TESTS+=test/test-cases/regression/issue-1591.json
90+
TESTS+=test/test-cases/regression/issue-1785.json
9091
TESTS+=test/test-cases/regression/variable-RESPONSE_HEADERS.json
9192
TESTS+=test/test-cases/regression/config-include.json
9293
TESTS+=test/test-cases/regression/variable-WEBSERVER_ERROR_LOG.json

src/utils/regex.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,16 @@ std::list<SMatch> Regex::searchAll(const std::string& s) {
9191
rc = 0;
9292
break;
9393
}
94-
if (len == 0) {
95-
rc = 0;
96-
break;
97-
}
9894
match.match = std::string(tmpString, start, len);
9995
match.m_offset = start;
10096
match.m_length = len;
10197
offset = start + len;
102-
10398
retList.push_front(match);
99+
100+
if (len == 0) {
101+
rc = 0;
102+
break;
103+
}
104104
}
105105
} while (rc > 0);
106106

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[
2+
{
3+
"enabled": 1,
4+
"version_min": 209000,
5+
"version_max": -1,
6+
"title": "Should libmodsec pass action clear m_actions?",
7+
"url": "https:\/\/github.com\/SpiderLabs\/ModSecurity\/issues\/1152",
8+
"client": {
9+
"ip": "200.249.12.31",
10+
"port": 2313
11+
},
12+
"server": {
13+
"ip": "200.249.12.31",
14+
"port": 80
15+
},
16+
"request": {
17+
"headers": {
18+
"Host": "net.tutsplus.com",
19+
"User-Agent": "",
20+
"Accept": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8",
21+
"Accept-Language": "en-us,en;q=0.5",
22+
"Accept-Encoding": "gzip,deflate",
23+
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
24+
"Keep-Alive": "300",
25+
"Connection": "keep-alive",
26+
"Cookie": "PHPSESSID=r2t5uvjq435r4q7ib3vtdjq120",
27+
"Pragma": "no-cache",
28+
"Cache-Control": "no-cache"
29+
},
30+
"uri": "\/test.pl?foo=bar",
31+
"method": "GET",
32+
"http_version": 1.1,
33+
"body": ""
34+
},
35+
"response": {
36+
"headers": {
37+
"Content-Type": "text\/xml; charset=utf-8\n\r",
38+
"Content-Length": "length\n\r"
39+
}
40+
},
41+
"expected": {
42+
"http_code": 403
43+
},
44+
"rules": [
45+
"SecRuleEngine On",
46+
"SecRule REQUEST_HEADERS:User-Agent \"^$\" \"id:'900017',phase:1,t:none,deny,nolog,msg:'foo = bar'\""
47+
]
48+
}
49+
]

0 commit comments

Comments
 (0)