diff options
-rw-r--r-- | src/libutil/regexp.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c index 5b3fca551..9f782472c 100644 --- a/src/libutil/regexp.c +++ b/src/libutil/regexp.c @@ -33,6 +33,8 @@ typedef guchar regexp_id_t[rspamd_cryptobox_HASHBYTES]; +#define DISABLE_JIT_FAST 1 + struct rspamd_regexp_s { gdouble exec_time; gchar *pattern; @@ -362,7 +364,7 @@ rspamd_regexp_search (rspamd_regexp_t *re, const gchar *text, gsize len, { pcre *r; pcre_extra *ext; -#if defined(HAVE_PCRE_JIT) && defined(HAVE_PCRE_JIT_FAST) +#if defined(HAVE_PCRE_JIT) && defined(HAVE_PCRE_JIT_FAST) && !defined(DISABLE_JIT_FAST) pcre_jit_stack *st = NULL; #endif const gchar *mt; @@ -398,17 +400,21 @@ rspamd_regexp_search (rspamd_regexp_t *re, const gchar *text, gsize len, if ((re->flags & RSPAMD_REGEXP_FLAG_RAW) || raw) { r = re->raw_re; ext = re->raw_extra; -#if defined(HAVE_PCRE_JIT) && defined(HAVE_PCRE_JIT_FAST) +#if defined(HAVE_PCRE_JIT) && defined(HAVE_PCRE_JIT_FAST) && !defined(DISABLE_JIT_FAST) st = re->raw_jstack; #endif } else { r = re->re; ext = re->extra; -#if defined(HAVE_PCRE_JIT) && defined(HAVE_PCRE_JIT_FAST) +#if defined(HAVE_PCRE_JIT) && defined(HAVE_PCRE_JIT_FAST) && !defined(DISABLE_JIT_FAST) if (g_utf8_validate (mt, remain, NULL)) { st = re->jstack; } + else { + msg_err ("bad utf8 input for JIT re"); + return FALSE; + } #endif } @@ -418,7 +424,7 @@ rspamd_regexp_search (rspamd_regexp_t *re, const gchar *text, gsize len, if (!(re->flags & RSPAMD_REGEXP_FLAG_NOOPT)) { #ifdef HAVE_PCRE_JIT -# ifdef HAVE_PCRE_JIT_FAST +# if defined(HAVE_PCRE_JIT_FAST) && !defined(DISABLE_JIT_FAST) /* XXX: flags seems to be broken with jit fast path */ g_assert (remain > 0); g_assert (mt != NULL); |