Allright, I got to the bottom of it. Turns out there is a real problem
with the way 4.1.10 (and before) handles parenthesized substring
matches in regular expressions. A clause like this:
acl greylist rcpt /(.*)/
will sooner rather than later cause a seg fault. Futhermore a clause like:
acl greylist rcpt /(unlikely_to_match)/
will cause a significant memory leak. The problem is not limited to
rcpt clauses and affects any regex in the access control list.
I have prepared a patch to resolve the seg fault in 4.1.10:
http://files.eschauzier.org/milter-greylist/regex_segfault-4.1.10.patch
It also cleans up some of the regex code. The issues resolved are the
following (in order of importance):
1. Fix segmentation fault with parenthesized substring matches in
regular expressions
Cause: the first set of pointers for storing the substring matches was
not initialized.
Remedy: move bzero statement to proper location in code
2. Memory leak with unmatched substrings
Cause: any time a regular expression with parenthesized substrings was
evaluated, but did not match, memory was allocated for storing the
substring matches, that was never freed.
Remedy: add appropriate free staments
3. Everytime a parenthesized substring match was being evaluated,
whether a match or not, a significant amount of reallocs, memmoves and
bzeroes took place, moving NULL pointer around.
Cause: memory was allocated for substring matches before an acutal
match occurred.
Remedy: allocate memory for substring matches after successful match
4. clause lists were evaluated in the opposite order of the conf file.
Eg. a acl statement like
list "test" domain {str1, str2, str3}
would be matched against str3 first, than str2, etc. Allthough this
does not affect functionality, it is very counter-intuitive. If a user
were to put the most likely matches at the top of the list to improve
performance, the effect would be a peformance hit. All other acl
elements are executed in their natural order.
Cause: use of list (lifo) structure for storing list elements.
Remedy: use stailq structure.Message
Re: Milter-greylist-4.1.10 segfaults on regular expressions
2009-02-08 by reschauzier
Attachments
- No local attachments were found for this message.