Fix `capture' memory management

The capture action was implemented before the transaction concept.
While partially ported to use the transaction, some of the elements
were not freed correctly. Now it is fully ported to use the class
Transaction.
This commit is contained in:
Felipe Zimmerle
2016-02-16 23:20:23 -03:00
parent e346454374
commit ed8b0c85d7
11 changed files with 17 additions and 37 deletions

View File

@@ -27,7 +27,7 @@ bool Contains::evaluate(Transaction *transaction, const std::string &input) {
bool contains = input.find(p) != std::string::npos;
if (contains) {
matched.push_back(p);
transaction->m_matched.push_back(p);
}
if (negation) {

View File

@@ -31,9 +31,8 @@ class Contains : public Operator {
/** @ingroup ModSecurity_Operator */
Contains(std::string op, std::string param, bool negation)
: Operator(op, param, negation) { }
bool evaluate(Transaction *transaction, const std::string &exp) override;
std::list<std::string> matched;
bool evaluate(Transaction *transaction, const std::string &exp) override;
};
} // namespace operators

View File

@@ -32,8 +32,8 @@ bool DetectSQLi::evaluate(Transaction *transaction, const std::string &input) {
issqli = libinjection_sqli(input.c_str(), input.length(), fingerprint);
if (issqli) {
matched.push_back(fingerprint);
if (transaction) {
transaction->m_matched.push_back(fingerprint);
#ifndef NO_LOGS
transaction->debug(4, "detected SQLi using libinjection with " \
"fingerprint '" + std::string(fingerprint) + "' at: '" +

View File

@@ -31,8 +31,6 @@ class DetectSQLi : public Operator {
: Operator(op, param, negation) { }
bool evaluate(Transaction *transaction, const std::string &input);
std::list<std::string> matched;
};
} // namespace operators

View File

@@ -78,7 +78,7 @@ bool Pm::evaluate(Transaction *transaction, const std::string &input) {
rc = acmp_process_quick(&pt, &match, input.c_str(), input.length());
if (rc == 1) {
this->matched.push_back(std::string(match));
transaction->m_matched.push_back(std::string(match));
}
return rc == 1;

View File

@@ -42,7 +42,6 @@ class Pm : public Operator {
bool init(const std::string &file, const char **error) override;
void postOrderTraversal(acmp_btree_node_t *node);
std::list<std::string> matched;
protected:
ACMP *m_p;
};

View File

@@ -30,7 +30,7 @@ bool Rx::evaluate(Transaction *transaction, const std::string& input) {
SMatch match;
if (regex_search(input, &match, *m_re) && match.size() >= 1) {
this->matched.push_back(match.match);
transaction->m_matched.push_back(match.match);
return true;
}

View File

@@ -42,7 +42,6 @@ class Rx : public Operator {
bool evaluate(Transaction *transaction, const std::string &input);
std::list<std::string> matched;
private:
std::string m_param;
Regex *m_re;