commit b1e451f: [Minor] Do not try to unpack streams with Predictor attribute

Vsevolod Stakhov vsevolod at highsecure.ru
Wed May 27 16:21:13 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-05-27 16:06:57 +0100
URL: https://github.com/rspamd/rspamd/commit/b1e451f0e19a5ca56498a1458532ffb31296615d

[Minor] Do not try to unpack streams with Predictor attribute

---
 lualib/lua_content/pdf.lua | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/lualib/lua_content/pdf.lua b/lualib/lua_content/pdf.lua
index 57968013f..785959dfe 100644
--- a/lualib/lua_content/pdf.lua
+++ b/lualib/lua_content/pdf.lua
@@ -391,7 +391,7 @@ local function apply_pdf_filter(input, filt)
 end
 
 -- Conditionally apply a pipeline of stream filters and return uncompressed data
-local function maybe_apply_filter(dict, data)
+local function maybe_apply_filter(dict, data, pdf, task)
   local uncompressed = data
 
   if dict.Filter then
@@ -400,6 +400,16 @@ local function maybe_apply_filter(dict, data)
       filt = {filt}
     end
 
+    if dict.DecodeParms then
+      local decode_params = maybe_dereference_object(dict.DecodeParms, pdf, task)
+
+      if type(decode_params) == 'table' then
+        if decode_params.Predictor then
+          return nil,'predictor exists'
+        end
+      end
+    end
+
     for _,f in ipairs(filt) do
       uncompressed = apply_pdf_filter(uncompressed, f)
 
@@ -407,7 +417,7 @@ local function maybe_apply_filter(dict, data)
     end
   end
 
-  return uncompressed
+  return uncompressed,nil
 end
 
 -- Conditionally extract stream data from object and attach it as obj.uncompressed
@@ -422,7 +432,7 @@ local function maybe_extract_object_stream(obj, pdf, task)
         tonumber(maybe_dereference_object(dict.Length, pdf, task)) or 0)
     local real_stream = obj.stream.data:span(1, len)
 
-    local uncompressed = maybe_apply_filter(dict, real_stream)
+    local uncompressed,filter_err = maybe_apply_filter(dict, real_stream, pdf, task)
 
     if uncompressed then
       obj.uncompressed = uncompressed
@@ -430,8 +440,8 @@ local function maybe_extract_object_stream(obj, pdf, task)
           obj.major, obj.minor, len, uncompressed:len())
       return obj.uncompressed
     else
-      lua_util.debugm(N, task, 'cannot extract object %s:%s; len = %s; filter = %s',
-          obj.major, obj.minor, len, dict.Filter)
+      lua_util.debugm(N, task, 'cannot extract object %s:%s; len = %s; filter = %s: %s',
+          obj.major, obj.minor, len, dict.Filter, filter_err)
     end
   end
 end


More information about the Commits mailing list