BUG/MINOR: regex: Properly handle PCRE2 lib compiled without JIT support
The PCRE2 JIT support is buggy. If HAProxy is compiled with USE_PCRE2_JIT option while the PCRE2 library is compiled without the JIT support, any matching will fail because pcre2_jit_compile() return value is not properly handled. We must fall back on pcre2_match() if PCRE2_ERROR_JIT_BADOPTION error is returned. This patch should fix the issue #1848. It must be backported as far as 2.4.
This commit is contained in:
parent
32872db605
commit
f348ecd67a
14
src/regex.c
14
src/regex.c
|
@ -372,12 +372,16 @@ struct my_regex *regex_comp(const char *str, int cs, int cap, char **err)
|
|||
* We end if it is an error not related to lack of JIT support
|
||||
* in a case of JIT support missing pcre2_jit_compile is "no-op"
|
||||
*/
|
||||
if (jit < 0 && jit != PCRE2_ERROR_JIT_BADOPTION) {
|
||||
pcre2_code_free(regex->reg);
|
||||
memprintf(err, "regex '%s' jit compilation failed", str);
|
||||
goto out_fail_alloc;
|
||||
} else {
|
||||
if (!jit)
|
||||
regex->mfn = &pcre2_jit_match;
|
||||
else {
|
||||
if (jit != PCRE2_ERROR_JIT_BADOPTION) {
|
||||
pcre2_code_free(regex->reg);
|
||||
memprintf(err, "regex '%s' jit compilation failed", str);
|
||||
goto out_fail_alloc;
|
||||
}
|
||||
else
|
||||
regex->mfn = &pcre2_match;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue