aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-11 13:05:59 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-11 13:05:59 +0100
commita43df55fa537d37c93d151b0c17578eefd83eb84 (patch)
treee658b1748ee332c5c6a8947a62c199338674081c /src/libmime
parent37a04a9e42001f376f69d2920315194f3098a0c4 (diff)
downloadrspamd-a43df55fa537d37c93d151b0c17578eefd83eb84.tar.gz
rspamd-a43df55fa537d37c93d151b0c17578eefd83eb84.zip
[Feature] Store hash of headers order and names
Diffstat (limited to 'src/libmime')
-rw-r--r--src/libmime/mime_headers.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index e44b14eaa..b4203f0d4 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -413,6 +413,9 @@ rspamd_mime_headers_process (struct rspamd_task *task, GHashTable *target,
if (check_newlines) {
guint max_cnt = 0;
gint sel = 0;
+ GList *cur;
+ rspamd_cryptobox_hash_state_t hs;
+ guchar hout[rspamd_cryptobox_HASHBYTES], *hexout;
for (gint i = 0; i < RSPAMD_TASK_NEWLINES_MAX; i ++) {
if (nlines_count[i] > max_cnt) {
@@ -422,6 +425,27 @@ rspamd_mime_headers_process (struct rspamd_task *task, GHashTable *target,
}
task->nlines_type = sel;
+
+ cur = order->head;
+ rspamd_cryptobox_hash_init (&hs, NULL, 0);
+
+ while (cur) {
+ nh = cur->data;
+
+ if (nh->name) {
+ rspamd_cryptobox_hash_update (&hs, nh->name, strlen (nh->name));
+ }
+
+ cur = g_list_next (cur);
+ }
+
+ rspamd_cryptobox_hash_final (&hs, hout);
+ hexout = rspamd_mempool_alloc (task->task_pool, sizeof (hout) * 2 + 1);
+ hexout[sizeof (hout) * 2] = '\0';
+ rspamd_encode_hex_buf (hout, sizeof (hout), hexout,
+ sizeof (hout) * 2 + 1);
+ rspamd_mempool_set_variable (task->task_pool, "headers_hash",
+ hexout, NULL);
}
}