commit 9d5a725: [Minor] Sigh, another condition fix

Vsevolod Stakhov vsevolod at highsecure.ru
Thu May 6 22:07:03 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-05-06 22:42:18 +0100
URL: https://github.com/rspamd/rspamd/commit/9d5a725bd691c385f9eb456c4f07440c0b518380 (HEAD -> master)

[Minor] Sigh, another condition fix

---
 lualib/lua_magic/heuristics.lua | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lualib/lua_magic/heuristics.lua b/lualib/lua_magic/heuristics.lua
index d977596ca..fc7743896 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


More information about the Commits mailing list