diff --git a/apache2/modsecurity.c b/apache2/modsecurity.c index a6891711..6b77132d 100644 --- a/apache2/modsecurity.c +++ b/apache2/modsecurity.c @@ -391,11 +391,9 @@ apr_status_t modsecurity_tx_init(modsec_rec *msr) { if (msr->matched_vars == NULL) return -1; apr_table_clear(msr->matched_vars); - if(msr->txcfg->max_rule_time > 0) { - msr->perf_rules = apr_table_make(msr->mp, 8); - if (msr->perf_rules == NULL) return -1; - apr_table_clear(msr->perf_rules); - } + msr->perf_rules = apr_table_make(msr->mp, 8); + if (msr->perf_rules == NULL) return -1; + apr_table_clear(msr->perf_rules); /* Locate the cookie headers and parse them */ arr = apr_table_elts(msr->request_headers); diff --git a/apache2/re.c b/apache2/re.c index 975d7e09..952a7867 100644 --- a/apache2/re.c +++ b/apache2/re.c @@ -2604,12 +2604,16 @@ static int execute_operator(msre_var *var, msre_rule *rule, modsec_rec *msr, rt_time = apr_table_get(msr->perf_rules, rule->actionset->id); if(rt_time == NULL) { rt_time = apr_psprintf(msr->mp, "%" APR_TIME_T_FMT, (t1 - time_before_op)); - apr_table_setn(msr->perf_rules, rule->actionset->id, rt_time); + rule_time = (apr_time_t)atoi(rt_time); + if(rule_time >= msr->txcfg->max_rule_time) + apr_table_setn(msr->perf_rules, rule->actionset->id, rt_time); } else { rule_time = (apr_time_t)atoi(rt_time); rule_time += (t1 - time_before_op); - rt_time = apr_psprintf(msr->mp, "%" APR_TIME_T_FMT, rule_time); - apr_table_setn(msr->perf_rules, rule->actionset->id, rt_time); + if(rule_time >= msr->txcfg->max_rule_time) { + rt_time = apr_psprintf(msr->mp, "%" APR_TIME_T_FMT, rule_time); + apr_table_setn(msr->perf_rules, rule->actionset->id, rt_time); + } } } }