mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-16 17:41:52 +03:00
Refactor regex code
This commit fixes quite a few odd things in regex code: * Lack of encapsulation. * Non-method functions for matching without retrieving all groups. * Regex class being copyable without proper copy-constructor (potential UAF and double free due to pointer members m_pc and m_pce). * Redundant SMatch::m_length, which always equals to match.size() anyway. * Weird SMatch::size_ member which is initialized only by one of the three matching functions, and equals to the return value of that function anyways. * Several places in code having std::string value instead of reference.
This commit is contained in:
@@ -130,14 +130,14 @@ bool VerifyCPF::evaluate(Transaction *t, Rule *rule,
|
||||
for (i = 0; i < input.size() - 1 && is_cpf == false; i++) {
|
||||
matches = m_re->searchAll(input.substr(i, input.size()));
|
||||
for (const auto & i : matches) {
|
||||
is_cpf = verify(i.match.c_str(), i.match.size());
|
||||
is_cpf = verify(i.str().c_str(), i.str().size());
|
||||
if (is_cpf) {
|
||||
logOffset(ruleMessage, i.m_offset, i.m_length);
|
||||
logOffset(ruleMessage, i.offset(), i.str().size());
|
||||
if (rule && t && rule->m_containsCaptureAction) {
|
||||
t->m_collections.m_tx_collection->storeOrUpdateFirst(
|
||||
"0", std::string(i.match));
|
||||
"0", i.str());
|
||||
ms_dbg_a(t, 7, "Added VerifyCPF match TX.0: " + \
|
||||
std::string(i.match));
|
||||
i.str());
|
||||
}
|
||||
|
||||
goto out;
|
||||
|
||||
Reference in New Issue
Block a user