diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-02-20 15:56:54 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-02-20 15:56:54 +0000 |
commit | 9bdb819160c5e4f1626b3ddbc76391d8c29995fd (patch) | |
tree | 7695578a793d0bd152b822decfafcc88f0fffefd /contrib/lua-lpeg | |
parent | 0f9f1f8e85a79ce759e92e1c120d51e88b97971f (diff) | |
download | rspamd-9bdb819160c5e4f1626b3ddbc76391d8c29995fd.tar.gz rspamd-9bdb819160c5e4f1626b3ddbc76391d8c29995fd.zip |
[Minor] Protect lpeg code against empty texts
Diffstat (limited to 'contrib/lua-lpeg')
-rw-r--r-- | contrib/lua-lpeg/lptree.c | 14 |
1 files changed, 14 insertions, 0 deletions
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); |