summaryrefslogtreecommitdiffstats
path: root/src/lua
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/lua
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/lua')
-rw-r--r--src/lua/lua_regexp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c
index 6e2b0dc22..4a209057e 100644
--- a/src/lua/lua_regexp.c
+++ b/src/lua/lua_regexp.c
@@ -543,6 +543,11 @@ lua_regexp_search(lua_State *L)
}
matched = TRUE;
+
+ if (start >= end) {
+ /* We found all matches, so no more hits are possible (protect from empty patterns) */
+ break;
+ }
}
if (!matched) {
@@ -749,7 +754,7 @@ lua_regexp_split(lua_State *L)
lua_rawseti(L, -2, ++i);
matched = TRUE;
}
- else if (start == end) {
+ else if (start >= end) {
break;
}
old_start = end;