Skip to content

Commit 72f632e

Browse files
Daniel Stelter-GlieseFelipe Zimmerle
authored andcommitted
Avoid additional operator invokation if last transform of a multimatch doesn't modify the input
Fixes #1086
1 parent 9ac9ff8 commit 72f632e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
DD MMM YYYY - 2.9.2 - To be released
22
------------------------------------
33

4+
* Avoid additional operator invokation if last transform of a multimatch
5+
doesn't modify the input
6+
[Issue #1086, #1087 - Daniel Stelter-Gliese]
47
* Adds a sanity check before use ctl:ruleRemoveTargetByTag.
58
[Issue #1353 - @LukeP21 and @zimmerle]
69
* Uses an optional global lock while manipulating collections.

apache2/re.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,7 +2872,10 @@ static apr_status_t msre_rule_process_normal(msre_rule *rule, modsec_rec *msr) {
28722872
arr = apr_table_elts(tartab);
28732873
te = (apr_table_entry_t *)arr->elts;
28742874
for (i = 0; i < arr->nelts; i++) {
2875+
/* Variable was modified by *any* transformation */
28752876
int changed;
2877+
/* Variable was modified by *last applied* transformation (needed by multimatch) */
2878+
int tfnchanged;
28762879
int usecache = 0;
28772880
apr_table_t *cachetab = NULL;
28782881
apr_time_t time_before_trans = 0;
@@ -2995,8 +2998,8 @@ static apr_status_t msre_rule_process_normal(msre_rule *rule, modsec_rec *msr) {
29952998
apr_table_t *normtab;
29962999
const char *lastvarval = NULL;
29973000
apr_size_t lastvarlen = 0;
2998-
int tfnchanged = 0;
29993001

3002+
tfnchanged = 0;
30003003
changed = 0;
30013004
normtab = apr_table_make(mptmp, 10);
30023005
if (normtab == NULL) return -1;
@@ -3278,7 +3281,7 @@ static apr_status_t msre_rule_process_normal(msre_rule *rule, modsec_rec *msr) {
32783281
* or if it is and we need to process the result of the
32793282
* last transformation.
32803283
*/
3281-
if (!multi_match || changed) {
3284+
if (!multi_match || tfnchanged) {
32823285
invocations++;
32833286

32843287
#if defined(PERFORMANCE_MEASUREMENT)

0 commit comments

Comments
 (0)