]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Lua_content: Fix a corner case when unpacking compound objects
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 1 Dec 2020 14:37:44 +0000 (14:37 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 1 Dec 2020 14:37:44 +0000 (14:37 +0000)
lualib/lua_content/pdf.lua

index 11d5cab46ee448e0074bc08b8908dd7e06bc3fe8..4e199b8b6b28a83b65b4a1bd973b60dee6d10c10 100644 (file)
@@ -811,7 +811,7 @@ local function pdf_compound_object_unpack(_, uncompressed, pdf, task, first)
           span_len = (elts[i + 1][2] + first) - offset
         end
 
-        if span_len > 0 and offset + span_len < #uncompressed then
+        if span_len > 0 and offset + span_len <= #uncompressed then
           local obj = {
             major = obj_number,
             minor = 0, -- Implicit
@@ -823,6 +823,9 @@ local function pdf_compound_object_unpack(_, uncompressed, pdf, task, first)
           if obj.dict then
             pdf.objects[#pdf.objects + 1] = obj
           end
+        else
+          lua_util.debugm(N, task, 'invalid span_len for compound object %s:%s; offset = %s, len = %s',
+              pair[1], pair[2], offset + span_len, #uncompressed)
         end
       end
     end