diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-09 15:08:08 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-09 15:08:08 +0000 |
commit | 63b90d3bf48ad144e7ff2318749cf3273dfdabe7 (patch) | |
tree | c348491185f5cb1b4f6217757c2cd81dc2c9eaa7 /src | |
parent | fdc148360fe650a9c418acd1e119bab388ac8c2f (diff) | |
download | rspamd-63b90d3bf48ad144e7ff2318749cf3273dfdabe7.tar.gz rspamd-63b90d3bf48ad144e7ff2318749cf3273dfdabe7.zip |
Fix setting limit for malformed regexps
Diffstat (limited to 'src')
-rw-r--r-- | src/libmime/mime_expressions.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c index bc13859c1..373ec955e 100644 --- a/src/libmime/mime_expressions.c +++ b/src/libmime/mime_expressions.c @@ -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); |