aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-07-29 17:35:00 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-07-29 17:35:00 +0100
commit47e8abad8456fd3cd46d98241c6bc9ca71cf9368 (patch)
tree7e2d2e51bb8d4c842884c38fa3184d2e6222bc0e /src/lua
parent0341427d1c80155636c3eb7426318264e7d3590d (diff)
downloadrspamd-47e8abad8456fd3cd46d98241c6bc9ca71cf9368.tar.gz
rspamd-47e8abad8456fd3cd46d98241c6bc9ca71cf9368.zip
[Minor] Fix content length calculations
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_html.cxx6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lua/lua_html.cxx b/src/lua/lua_html.cxx
index 9a562d2fa..2b0f63c02 100644
--- a/src/lua/lua_html.cxx
+++ b/src/lua/lua_html.cxx
@@ -580,8 +580,10 @@ lua_html_tag_get_content (lua_State *L)
if (ltag) {
auto clen = ltag->tag->get_content_length();
- if (ltag->html && clen &&
- ltag->html->parsed.size() >= ltag->tag->content_offset + clen) {
+ if (ltag->html && clen && ltag->html->parsed.size() > ltag->tag->content_offset) {
+ if (ltag->html->parsed.size() - ltag->tag->content_offset < clen) {
+ clen = ltag->html->parsed.size() - ltag->tag->content_offset;
+ }
t = static_cast<rspamd_lua_text *>(lua_newuserdata(L, sizeof(*t)));
rspamd_lua_setclass (L, "rspamd{text}", -1);
t->start = reinterpret_cast<const char *>(ltag->html->parsed.data()) +