]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Oops, fix memory drainage
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Feb 2019 17:47:01 +0000 (17:47 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Feb 2019 17:47:01 +0000 (17:47 +0000)
src/libmime/mime_headers.c
test/lua/unit/received.lua

index 0a79e3441254c66790c3416a881be07ad2fae1c9..d0388a6323bc3c38624257cbd481a8ae29f63369 100644 (file)
@@ -1092,10 +1092,14 @@ rspamd_smtp_received_process_part (struct rspamd_task *task,
                                                &npart->data, &npart->dlen);
                        }
 
+                       *last = p - (const guchar *)data;
+
                        return npart;
                }
                break;
        case skip_spaces:
+               *last = p - (const guchar *)data;
+
                return npart;
        default:
                break;
@@ -1141,6 +1145,7 @@ rspamd_smtp_received_spill (struct rspamd_task *task,
                return NULL;
        }
 
+       g_assert (pos != 0);
        p += pos;
        len = end > p ? end - p : 0;
        DL_APPEND (head, cur_part);
@@ -1157,6 +1162,7 @@ rspamd_smtp_received_spill (struct rspamd_task *task,
                        return NULL;
                }
 
+               g_assert (pos != 0);
                p += pos;
                len = end > p ? end - p : 0;
                DL_APPEND (head, cur_part);
@@ -1212,6 +1218,7 @@ rspamd_smtp_received_spill (struct rspamd_task *task,
                                return NULL;
                        }
                        else {
+                               g_assert (pos != 0);
                                p += pos;
                                len = end > p ? end - p : 0;
                                DL_APPEND (head, cur_part);
index 19decc39722c2d013f19ea90bf6fe8b2ddef3030..c633a99b1e7fad7a7f2b09ce810cf32a05dca4e0 100644 (file)
@@ -25,6 +25,12 @@ context("Received headers parser", function()
   ]]
 
   local cases = {
+    {[[from smtp11.mailtrack.pl (smtp11.mailtrack.pl [185.243.30.90])]],
+     {
+       real_ip = '185.243.30.90',
+       real_hostname = 'smtp11.mailtrack.pl'
+     },
+    },
     {[[from asx121.turbo-inline.com [7.165.23.113] by mx.reskind.net with QMQP; Fri, 08 Feb 2019 06:56:18 -0500]],
      {
        real_ip = '7.165.23.113',