commit c1f9bfc: [Fix] Fix parsing of the received headers with empty part
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Oct 1 14:07:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-10-01 15:03:10 +0100
URL: https://github.com/rspamd/rspamd/commit/c1f9bfc86391e4be50a5fbd16a7b899288a3a84c (HEAD -> master)
[Fix] Fix parsing of the received headers with empty part
---
src/libmime/mime_headers.c | 16 ++++++++++++----
test/lua/unit/received.lua | 9 ++++++++-
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index e83debc43..f7eb86f2e 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -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;
}
diff --git a/test/lua/unit/received.lua b/test/lua/unit/received.lua
index fc1f24de8..908c1904e 100644
--- a/test/lua/unit/received.lua
+++ b/test/lua/unit/received.lua
@@ -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)
More information about the Commits
mailing list