]> source.dussan.org Git - rspamd.git/commitdiff
Disable fast path of pcre as it seems to be broken
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 18 Jan 2016 00:48:53 +0000 (00:48 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 18 Jan 2016 00:48:53 +0000 (00:48 +0000)
src/libutil/regexp.c

index 5b3fca5519a2ddaad53c8b320206e43a8e8f8418..9f782472cf62a54453b74efdf49ccae0e0d6f885 100644 (file)
@@ -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);