]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix parsing of the received headers with empty part
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 1 Oct 2019 14:03:10 +0000 (15:03 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 1 Oct 2019 14:03:10 +0000 (15:03 +0100)
src/libmime/mime_headers.c
test/lua/unit/received.lua

index e83debc43def8c8d0d3e8dd356f5d54be6f61905..f7eb86f2ec5ed6599ae83aa10ad0a73ec02922c5 100644 (file)
@@ -1098,8 +1098,14 @@ rspamd_smtp_received_process_part (struct rspamd_task *task,
                        p ++;
                        break;
                case all_done:
-                       *last = p - (const guchar *)data;
-                       return npart;
+                       if (p > (const guchar *)data) {
+                               *last = p - (const guchar *) data;
+                               return npart;
+                       }
+                       else {
+                               /* Empty element */
+                               return NULL;
+                       }
                        break;
                }
        }
@@ -1120,9 +1126,11 @@ rspamd_smtp_received_process_part (struct rspamd_task *task,
                }
                break;
        case skip_spaces:
-               *last = p - (const guchar *)data;
+               if (p > c) {
+                       *last = p - (const guchar *) data;
 
-               return npart;
+                       return npart;
+               }
        default:
                break;
        }
index fc1f24de8b2d6ad3cb840164b1f8c49f8a02ac2e..908c1904ef4caf5fd4e0cd7cb69efc4fb0262125 100644 (file)
@@ -121,7 +121,14 @@ context("Received headers parser", function()
       {
         by_hostname = 'example.com',
       },
-    }
+    },
+    {[[from 171-29.br (1-1-1-1.z.com.br [1.1.1.1]) by x.com.br (Postfix) with;ESMTP id 44QShF6xj4z1X for <y.br>; Thu, 21 Mar 2019 23:45:46 -0300 : <g @yi.br>]],
+       {
+         from_hostname = '171-29.br',
+         real_ip = '1.1.1.1',
+         by_hostname = 'x.com.br',
+       }
+    },
   }
 
   local task = ffi.C.rspamd_task_new(nil, nil)