commit 9bdb819: [Minor] Protect lpeg code against empty texts
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Feb 20 16:00:08 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-02-20 15:56:54 +0000
URL: https://github.com/rspamd/rspamd/commit/9bdb819160c5e4f1626b3ddbc76391d8c29995fd (HEAD -> master)
[Minor] Protect lpeg code against empty texts
---
contrib/lua-lpeg/lptree.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/contrib/lua-lpeg/lptree.c b/contrib/lua-lpeg/lptree.c
index ffc03f770..f4a58dbf0 100644
--- a/contrib/lua-lpeg/lptree.c
+++ b/contrib/lua-lpeg/lptree.c
@@ -1167,12 +1167,26 @@ static int lp_match (lua_State *L) {
else if (lua_type (L, SUBJIDX) == LUA_TUSERDATA) {
struct rspamd_lua_text *t = lua_check_text (L, SUBJIDX);
if (!t) {
+#ifdef LPEG_LUD_WORKAROUND
+ lpeg_free_mem_low (capture);
+#endif
return luaL_error (L, "invalid argument (not a text)");
}
s = t->start;
l = t->len;
+
+ if (s == NULL) {
+ lua_pushnil(L);
+#ifdef LPEG_LUD_WORKAROUND
+ lpeg_free_mem_low (capture);
+#endif
+ return 1;
+ }
}
else {
+#ifdef LPEG_LUD_WORKAROUND
+ lpeg_free_mem_low (capture);
+#endif
return luaL_error (L, "invalid argument");
}
size_t i = initposition(L, l);
More information about the Commits
mailing list