From: Vsevolod Stakhov Date: Thu, 6 May 2021 21:42:18 +0000 (+0100) Subject: [Minor] Sigh, another condition fix X-Git-Tag: 3.0~426 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d5a725bd691c385f9eb456c4f07440c0b518380;p=thirdparty%2Frspamd.git [Minor] Sigh, another condition fix --- diff --git a/lualib/lua_magic/heuristics.lua b/lualib/lua_magic/heuristics.lua index d977596cad..fc77438967 100644 --- a/lualib/lua_magic/heuristics.lua +++ b/lualib/lua_magic/heuristics.lua @@ -329,11 +329,11 @@ exports.text_part_heuristic = function(part, log_obj, _) local function is_span_text(span) -- We examine 8 bit content, and we assume it might be localized text -- if it has more than 3 subsequent 8 bit characters - local function rough_8bit_check(bytes, idx, remain) + local function rough_8bit_check(bytes, idx, remain, len) local b = bytes[idx] local n8bit = 0 - while b >= 127 and idx < remain do + while b >= 127 and idx <= len do -- utf8 part if bit.band(b, 0xe0) == 0xc0 and remain > 1 and bit.band(bytes[idx + 1], 0xc0) == 0x80 then @@ -372,7 +372,7 @@ exports.text_part_heuristic = function(part, log_obj, _) if (b < 0x20) and not (b == 0x0d or b == 0x0a or b == 0x09) then non_printable = non_printable + 1 elseif b >= 127 then - local c,nskip = rough_8bit_check(bytes, i, tlen - i) + local c,nskip = rough_8bit_check(bytes, i, tlen - i, tlen) if not c then non_printable = non_printable + 1