commit 9908a43: [Minor] Rspamadm fix use after free

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Jan 19 17:14:07 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-01-19 17:10:58 +0000
URL: https://github.com/rspamd/rspamd/commit/9908a4360a4433d02f45e4cd3f7e8bb380e77594 (HEAD -> master)

[Minor] Rspamadm fix use after free

---
 lualib/rspamadm/mime.lua | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lualib/rspamadm/mime.lua b/lualib/rspamadm/mime.lua
index 6294f373f..8bd2478c8 100644
--- a/lualib/rspamadm/mime.lua
+++ b/lualib/rspamadm/mime.lua
@@ -266,6 +266,7 @@ end
 
 local function extract_handler(opts)
   local out_elts = {}
+  local tasks = {}
   local process_func
 
   if opts.words then
@@ -415,11 +416,12 @@ local function extract_handler(opts)
     end
 
     table.insert(out_elts[fname], "")
-
-    task:destroy() -- No automatic dtor
+    table.insert(tasks, task)
   end
 
   print_elts(out_elts, opts, process_func)
+  -- To avoid use after free we postpone tasks destruction
+  for _,task in ipairs(tasks) do task:destroy() end
 end
 
 local function stat_handler(opts)


More information about the Commits mailing list