summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-10-21 15:52:50 +0100
committerAndrew Lewis <nerf@judo.za.org>2017-10-21 21:03:22 +0200
commit417974301409337bbbd83436c4c916278b374ac4 (patch)
tree8ae02547c4d7b43ee3fb0e9e1f36a74c38397e8f /src
parentdd3aaa9dc4238770e401a00a545c60360ec91591 (diff)
downloadrspamd-417974301409337bbbd83436c4c916278b374ac4.tar.gz
rspamd-417974301409337bbbd83436c4c916278b374ac4.zip
[Fix] Fix multiple headers in DKIM headers list
MFH: rspamd-1.6 Issue: #1876
Diffstat (limited to 'src')
-rw-r--r--src/libserver/dkim.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c
index 2b5357145..83b4bc713 100644
--- a/src/libserver/dkim.c
+++ b/src/libserver/dkim.c
@@ -394,6 +394,7 @@ rspamd_dkim_parse_hdrlist_common (struct rspamd_dkim_common_ctx *ctx,
gboolean from_found = FALSE;
guint count = 0;
struct rspamd_dkim_header *new;
+ gpointer found;
GHashTable *htb;
p = param;
@@ -417,30 +418,37 @@ rspamd_dkim_parse_hdrlist_common (struct rspamd_dkim_common_ctx *ctx,
while (p <= end) {
if ((p == end || *p == ':') && p - c > 0) {
+
h = rspamd_mempool_alloc (ctx->pool, p - c + 1);
rspamd_strlcpy (h, c, p - c + 1);
- g_strstrip (h);
- new = rspamd_mempool_alloc (ctx->pool,
- sizeof (struct rspamd_dkim_header));
- new->name = h;
- new->count = 0;
+ g_strstrip (h);
/* Check mandatory from */
if (!from_found && g_ascii_strcasecmp (h, "from") == 0) {
from_found = TRUE;
}
+ new = rspamd_mempool_alloc (ctx->pool,
+ sizeof (struct rspamd_dkim_header));
+ new->name = h;
+ new->count = 0;
+
g_ptr_array_add (ctx->hlist, new);
- if (g_hash_table_lookup (htb, h) != NULL) {
- new->count++;
+ if ((found = g_hash_table_lookup (htb, h)) != NULL) {
+ count = GPOINTER_TO_UINT (found);
+ new->count = count;
+ count ++;
+ g_hash_table_insert (htb, h, GUINT_TO_POINTER (count));
}
else {
- /* Insert new header to the list */
- g_hash_table_insert (htb, (gpointer)new->name, new);
+ /* Insert new header order to the list */
+ count = new->count + 1;
}
+ g_hash_table_insert (htb, h, GUINT_TO_POINTER (count));
+
c = p + 1;
p++;
}