diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-08-24 16:19:25 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-08-24 16:19:25 +0100 |
commit | 2802836b8a2fb32ed46f943d96d882633b714196 (patch) | |
tree | c23ba359324adf2e9714cc3b16d2e9f59455600a /src/libutil/regexp.c | |
parent | 94f656018d8e26ffe7b91897ee159001ab4c3a5f (diff) | |
download | rspamd-2802836b8a2fb32ed46f943d96d882633b714196.tar.gz rspamd-2802836b8a2fb32ed46f943d96d882633b714196.zip |
[Minor] Fix match limit feature in regexps
Diffstat (limited to 'src/libutil/regexp.c')
-rw-r--r-- | src/libutil/regexp.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c index 584c0c5c9..46ed9a0df 100644 --- a/src/libutil/regexp.c +++ b/src/libutil/regexp.c @@ -66,6 +66,7 @@ struct rspamd_regexp_s { gpointer ud; gpointer re_class; guint64 cache_id; + gsize match_limit; guint max_hits; gint flags; gint pcre_flags; @@ -567,6 +568,10 @@ rspamd_regexp_search (const rspamd_regexp_t *re, const gchar *text, gsize len, len = strlen (text); } + if (re->match_limit > 0 && len > re->match_limit) { + len = re->match_limit; + } + if (end != NULL && *end != NULL) { /* Incremental search */ mt = (*end); @@ -889,6 +894,26 @@ rspamd_regexp_set_cache_id (rspamd_regexp_t *re, guint64 id) return old; } +gsize +rspamd_regexp_get_match_limit (const rspamd_regexp_t *re) +{ + g_assert (re != NULL); + + return re->match_limit; +} + +gsize +rspamd_regexp_set_match_limit (rspamd_regexp_t *re, gsize lim) +{ + gsize old; + + g_assert (re != NULL); + old = re->match_limit; + re->match_limit = lim; + + return old; +} + gboolean rspamd_regexp_match (const rspamd_regexp_t *re, const gchar *text, gsize len, gboolean raw) |