commit 462ab60: [Minor] Oops, fix memory drainage

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Feb 8 17:49:07 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-02-08 17:47:01 +0000
URL: https://github.com/rspamd/rspamd/commit/462ab60be82e8be85ffa32e2a15883cf7486f0dd (HEAD -> master)

[Minor] Oops, fix memory drainage

---
 src/libmime/mime_headers.c | 7 +++++++
 test/lua/unit/received.lua | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index 0a79e3441..d0388a632 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -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);
diff --git a/test/lua/unit/received.lua b/test/lua/unit/received.lua
index 19decc397..c633a99b1 100644
--- a/test/lua/unit/received.lua
+++ b/test/lua/unit/received.lua
@@ -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',


More information about the Commits mailing list