commit 87ef908: [Fix] Fix off-by-one with init check
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Nov 18 17:56:08 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-11-18 17:50:19 +0000
URL: https://github.com/rspamd/rspamd/commit/87ef9084fbc26218762f7b9a90522507543d142a (HEAD -> master)
[Fix] Fix off-by-one with init check
---
src/lua/lua_text.c | 2 +-
test/lua/unit/rspamd_text.lua | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/lua/lua_text.c b/src/lua/lua_text.c
index 99b8b8151..dbbba9838 100644
--- a/src/lua/lua_text.c
+++ b/src/lua/lua_text.c
@@ -1358,7 +1358,7 @@ lua_text_find (lua_State *L)
init = relative_pos_start (lua_tointeger (L, 3), t->len);
}
- if (init >= t->len) {
+ if (init > t->len) {
return luaL_error (L, "invalid arguments to find: init too large");
}
diff --git a/test/lua/unit/rspamd_text.lua b/test/lua/unit/rspamd_text.lua
index 4e3a5e8e7..3e6d0fff7 100644
--- a/test/lua/unit/rspamd_text.lua
+++ b/test/lua/unit/rspamd_text.lua
@@ -37,6 +37,8 @@ context("Rspamd_text:find() test", function()
{{'foobarfoo', 'bar'}, {4, 6}},
{{'foobarfoo', 'baz'}, nil},
{{'foobarfoo', 'rfoo'}, {6, 9}},
+ {{'foo', 'bar'}, nil},
+ {{'x', 'xxxx'}, nil},
}
for _, case in ipairs(cases) do
More information about the Commits
mailing list