]> source.dussan.org Git - rspamd.git/commitdiff
[CritFix] Fix regexps results combination
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Apr 2016 16:05:42 +0000 (17:05 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Apr 2016 16:05:42 +0000 (17:05 +0100)
When converting to vectored mode we need to remember results between
consequent calls of regexp match engine. Prior to this patch this
behaviour was broken and caused regexp rules to be matched incorrectly.

src/libserver/re_cache.c

index 2e3a2ff653348a7b83ce150333b74a10f0c8994f..41f942f22fdaf097d904df26c11eed1f2a254f5b 100644 (file)
@@ -467,6 +467,10 @@ rspamd_re_cache_process_pcre (struct rspamd_re_runtime *rt,
        gdouble t1, t2;
        const gdouble slow_time = 0.1;
 
+       if (in == NULL) {
+               return rt->results[id];
+       }
+
        if (len == 0) {
                len = strlen (in);
        }
@@ -605,9 +609,10 @@ rspamd_re_cache_process_regexp_data (struct rspamd_re_runtime *rt,
                                in[i],
                                lens[i],
                                is_raw);
+               rt->results[re_id] = ret;
        }
+
        setbit (rt->checked, re_id);
-       rt->results[re_id] = ret;
 #else
        struct rspamd_re_cache_elt *elt;
        struct rspamd_re_class *re_class;
@@ -624,10 +629,10 @@ rspamd_re_cache_process_regexp_data (struct rspamd_re_runtime *rt,
                                        in[i],
                                        lens[i],
                                        is_raw);
+                       rt->results[re_id] = ret;
                }
 
                setbit (rt->checked, re_id);
-               rt->results[re_id] = ret;
        }
        else {
                for (i = 0; i < count; i ++) {