Commit f732fc6
committed
Allocate regex in request's mempoll in @rx execute
If regex contains variable substitution, function
msre_op_rx_execute(), which handles execution of @rx operator,
will compile regex on each request (because variable, and this
regex, can be different each time). It does so by calling
msc_pregcomp_ex(), which accepts a mem pool because it does
allocations for regex data. Until this fix, msre_op_rx_execute()
passed rule->ruleset->mp to msc_pregcomp_ex(), which is a ruleset
mempool that persists as long as ruleset lives - which means it
is long-living and will persist until ModSecurity is
stopped/restarted. This created a memory leak because regex data
for non-constand regexes was allocated again to each request and
not freed after request was processed.
Fix that by passing msr->mp mempool to msc_pregcomp_ex() instead,
which is a mempool of record corresponding to a tx being processed
and will be freed as soon as processing is done.1 parent 12cefbd commit f732fc6
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1018 | 1018 | | |
1019 | 1019 | | |
1020 | 1020 | | |
1021 | | - | |
| 1021 | + | |
1022 | 1022 | | |
1023 | 1023 | | |
1024 | 1024 | | |
| |||
0 commit comments