Skip to content

Commit ff8085c

Browse files
committed
Removed unnecessary lock to call acmp_process_quick in Pm::evaluate
- This was introduced in commit 119a6fc & 7d786b3 because of a potential issue reported in owasp-modsecurity#1573. - The ACMP tree structure is initialized when the operator is initialized. - During transaction execution the ACMP tree structure is only 'read' while traversing the tree (in acmp_process_quick) so this is safe for use in a multi-threaded environment.
1 parent 7a6052a commit ff8085c

File tree

2 files changed

+0
-18
lines changed

2 files changed

+0
-18
lines changed

src/operators/pm.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ Pm::~Pm() {
3939

4040
free(m_p);
4141
m_p = NULL;
42-
#ifdef MODSEC_MUTEX_ON_PM
43-
pthread_mutex_destroy(&m_lock);
44-
#endif
4542
}
4643

4744

@@ -88,13 +85,7 @@ bool Pm::evaluate(Transaction *transaction, RuleWithActions *rule,
8885
pt.parser = m_p;
8986
pt.ptr = NULL;
9087
const char *match = NULL;
91-
#ifdef MODSEC_MUTEX_ON_PM
92-
pthread_mutex_lock(&m_lock);
93-
#endif
9488
rc = acmp_process_quick(&pt, &match, input.c_str(), input.length());
95-
#ifdef MODSEC_MUTEX_ON_PM
96-
pthread_mutex_unlock(&m_lock);
97-
#endif
9889

9990
if (rc >= 0 && transaction) {
10091
std::string match_(match?match:"");
@@ -118,9 +109,6 @@ bool Pm::init(const std::string &file, std::string *error) {
118109
std::istringstream *iss;
119110
const char *err = NULL;
120111

121-
#ifdef MODSEC_MUTEX_ON_PM
122-
pthread_mutex_init(&m_lock, NULL);
123-
#endif
124112
char *content = parse_pm_content(m_param.c_str(), m_param.length(), &err);
125113
if (content == NULL) {
126114
iss = new std::istringstream(m_param);

src/operators/pm.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ class Pm : public Operator {
5252

5353
protected:
5454
ACMP *m_p;
55-
56-
#ifdef MODSEC_MUTEX_ON_PM
57-
58-
private:
59-
pthread_mutex_t m_lock;
60-
#endif
6155
};
6256

6357

0 commit comments

Comments
 (0)