aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-03-22 17:07:58 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-03-22 17:07:58 +0000
commit2038f3c92afaaeceab3e7107a38c06f8d555ae53 (patch)
tree707f8ed7a9cde54f0466772ac90270cbedee6f7d /src/libserver
parent05636d9af847923a6f1e538897b085cb3dcdf5d0 (diff)
downloadrspamd-2038f3c92afaaeceab3e7107a38c06f8d555ae53.tar.gz
rspamd-2038f3c92afaaeceab3e7107a38c06f8d555ae53.zip
[CritFix] Protect regexp matcher from regexps with empty patterns
Issue: #4885 Closes: #4885
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/re_cache.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index 647375bcd..0644980da 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -632,6 +632,11 @@ rspamd_re_cache_process_pcre(struct rspamd_re_runtime *rt,
if (max_hits > 0 && r >= max_hits) {
break;
}
+
+ if (start >= end) {
+ /* We found all matches, so no more hits are possible (protect from empty patterns) */
+ break;
+ }
}
rt->results[id] += r;