]> source.dussan.org Git - rspamd.git/commitdiff
Fix setting limit for malformed regexps
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 9 Dec 2015 15:08:08 +0000 (15:08 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 9 Dec 2015 15:08:08 +0000 (15:08 +0000)
src/libmime/mime_expressions.c

index bc13859c1425ae189c0934636a8fd63eddcb793e..373ec955ecf6a6c2a16c31ec56202354ae8b8e78 100644 (file)
@@ -274,6 +274,7 @@ rspamd_mime_expr_parse_regexp_atom (rspamd_mempool_t * pool, const gchar *line)
        /* Parse flags */
        p = end + 1;
        re_flags = g_string_sized_new (32);
+
        while (p != NULL) {
                switch (*p) {
                case 'i':
@@ -342,13 +343,6 @@ rspamd_mime_expr_parse_regexp_atom (rspamd_mempool_t * pool, const gchar *line)
        result->regexp = rspamd_regexp_new (dbegin, re_flags->str,
                        &err);
 
-       if (result->is_multiple) {
-               rspamd_regexp_set_maxhits (result->regexp, 0);
-       }
-       else {
-               rspamd_regexp_set_maxhits (result->regexp, 1);
-       }
-
        g_string_free (re_flags, TRUE);
 
        if (result->regexp == NULL || err != NULL) {
@@ -358,6 +352,15 @@ rspamd_mime_expr_parse_regexp_atom (rspamd_mempool_t * pool, const gchar *line)
                return NULL;
        }
 
+       if (result->regexp) {
+               if (result->is_multiple) {
+                       rspamd_regexp_set_maxhits (result->regexp, 0);
+               }
+               else {
+                       rspamd_regexp_set_maxhits (result->regexp, 1);
+               }
+       }
+
        rspamd_mempool_add_destructor (pool,
                (rspamd_mempool_destruct_t) rspamd_regexp_unref,
                (void *)result->regexp);