summaryrefslogtreecommitdiffstats
path: root/lualib/lua_magic
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-06-16 13:52:32 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-06-16 13:52:32 +0100
commit95c95db6d47d3ab5232dd4bb22bbee6719d6a5cf (patch)
treeaac468609d57807b27d35fbb0695de68425c18c7 /lualib/lua_magic
parentcf3464d9ba9e7cbcde820679855919eadd3663e4 (diff)
downloadrspamd-95c95db6d47d3ab5232dd4bb22bbee6719d6a5cf.tar.gz
rspamd-95c95db6d47d3ab5232dd4bb22bbee6719d6a5cf.zip
[Minor] Add sanity check
Diffstat (limited to 'lualib/lua_magic')
-rw-r--r--lualib/lua_magic/heuristics.lua44
1 files changed, 23 insertions, 21 deletions
diff --git a/lualib/lua_magic/heuristics.lua b/lualib/lua_magic/heuristics.lua
index 678ca1b6d..82c2fa4bd 100644
--- a/lualib/lua_magic/heuristics.lua
+++ b/lualib/lua_magic/heuristics.lua
@@ -183,32 +183,34 @@ local function detect_ole_format(input, log_obj, _, part)
local dtype = input:at(offset + 66)
lua_util.debugm(N, log_obj, "dtype: %s, offset: %s", dtype, offset)
- if dtype == 5 then
- -- Extract clsid
- local matches = msoffice_trie_clsid:match(input:span(offset + 80, 16))
- if matches then
- for n,_ in pairs(matches) do
- if msoffice_clsid_indexes[n] then
- lua_util.debugm(N, log_obj, "found valid clsid for %s",
- msoffice_clsid_indexes[n][1])
- return true,msoffice_clsid_indexes[n][1]
+ if dtype then
+ if dtype == 5 then
+ -- Extract clsid
+ local matches = msoffice_trie_clsid:match(input:span(offset + 80, 16))
+ if matches then
+ for n,_ in pairs(matches) do
+ if msoffice_clsid_indexes[n] then
+ lua_util.debugm(N, log_obj, "found valid clsid for %s",
+ msoffice_clsid_indexes[n][1])
+ return true,msoffice_clsid_indexes[n][1]
+ end
end
end
- end
- return true,nil
- elseif dtype == 2 then
- local matches = msoffice_trie:match(input:span(offset, 64))
- if matches then
- for n,_ in pairs(matches) do
- if msoffice_patterns_indexes[n] then
- return true,msoffice_patterns_indexes[n][1]
+ return true,nil
+ elseif dtype == 2 then
+ local matches = msoffice_trie:match(input:span(offset, 64))
+ if matches then
+ for n,_ in pairs(matches) do
+ if msoffice_patterns_indexes[n] then
+ return true,msoffice_patterns_indexes[n][1]
+ end
end
end
+ return true,nil
+ elseif dtype >= 0 and dtype < 5 then
+ -- Bad type
+ return true,nil
end
- return true,nil
- elseif dtype >= 0 and dtype < 5 then
- -- Bad type
- return true,nil
end
return false,nil