mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Fix substring constructor in regex search all
Apparently the substring constructor for std::string cannot handle well \0 characters. Leading to a crash. Issue reported on #1304
This commit is contained in:
parent
e181cb7e0a
commit
36d6bb9664
@ -77,18 +77,20 @@ std::list<SMatch> Regex::searchAll(const std::string& s) {
|
||||
int i;
|
||||
const char *subject = s.c_str();
|
||||
int rc;
|
||||
const std::string tmpString = std::string(s.c_str(), s.size());
|
||||
|
||||
rc = pcre_exec(m_pc, m_pce, subject,
|
||||
s.size(), 0, 0, ovector, OVECCOUNT);
|
||||
|
||||
for (i = 0; i < rc; i++) {
|
||||
SMatch match;
|
||||
const char *substring_start = subject + ovector[2*i];
|
||||
int substring_length = ovector[2*i+1] - ovector[2*i];
|
||||
|
||||
match.match = std::string(subject, ovector[2*i],
|
||||
substring_length);
|
||||
|
||||
size_t start = ovector[2*i];
|
||||
size_t end = ovector[2*i+1];
|
||||
size_t len = end - start;
|
||||
if (end >= s.size()) {
|
||||
continue;
|
||||
}
|
||||
match.match = std::string(tmpString, start, len);
|
||||
retList.push_front(match);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user