]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: regex: fix pcre_study error handling
authorChristian Ruppert <c.ruppert@babiel.com>
Wed, 29 Oct 2014 16:05:53 +0000 (17:05 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 29 Oct 2014 16:44:31 +0000 (17:44 +0100)
pcre_study() may return NULL even though it succeeded. In this case error is
NULL otherwise error is not NULL. Also see man 3 pcre_study.

Previously a ACL pattern of e.g. ".*" would cause error because pcre_study did
not found anything to speed up matching and returned regex->extra = NULL and
error = NULL which in this case was a false-positive. That happend only when
PCRE_JIT was enabled for HAProxy but libpcre has been built without JIT.

Signed-off-by: Christian Ruppert <c.ruppert@babiel.com>
[wt: this needs to be backported to 1.5 as well]

src/regex.c

index dda666db22083fc4c840c1745731be087e91ab09..c0b23cb12515f3a584209666938ae902e44e23b5 100644 (file)
@@ -290,7 +290,7 @@ int regex_comp(const char *str, struct my_regex *regex, int cs, int cap, char **
 
 #ifdef USE_PCRE_JIT
        regex->extra = pcre_study(regex->reg, PCRE_STUDY_JIT_COMPILE, &error);
-       if (!regex->extra) {
+       if (!regex->extra && error != NULL) {
                pcre_free(regex->reg);
                memprintf(err, "failed to compile regex '%s' (error=%s)", str, error);
                return 0;