mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 23:56:57 +02:00
BUG/MEDIUM: regex: fix pcre_study error handling
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]
This commit is contained in:
parent
a616ba6f5f
commit
955f4613cb
@ -290,7 +290,7 @@ int regex_comp(const char *str, struct my_regex *regex, int cs, int cap, char **
|
|||||||
|
|
||||||
#ifdef USE_PCRE_JIT
|
#ifdef USE_PCRE_JIT
|
||||||
regex->extra = pcre_study(regex->reg, PCRE_STUDY_JIT_COMPILE, &error);
|
regex->extra = pcre_study(regex->reg, PCRE_STUDY_JIT_COMPILE, &error);
|
||||||
if (!regex->extra) {
|
if (!regex->extra && error != NULL) {
|
||||||
pcre_free(regex->reg);
|
pcre_free(regex->reg);
|
||||||
memprintf(err, "failed to compile regex '%s' (error=%s)", str, error);
|
memprintf(err, "failed to compile regex '%s' (error=%s)", str, error);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user