diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-11-18 17:50:19 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-11-18 17:50:19 +0000 |
commit | 87ef9084fbc26218762f7b9a90522507543d142a (patch) | |
tree | a99d8c1b90803166a10ec872467a47adf9076e35 | |
parent | d6de1382a4e2c0ff723f1ee65c8e64c81fb0a76c (diff) | |
download | rspamd-87ef9084fbc26218762f7b9a90522507543d142a.tar.gz rspamd-87ef9084fbc26218762f7b9a90522507543d142a.zip |
[Fix] Fix off-by-one with init check
-rw-r--r-- | src/lua/lua_text.c | 2 | ||||
-rw-r--r-- | test/lua/unit/rspamd_text.lua | 2 |
2 files changed, 3 insertions, 1 deletions
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 |