diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-09-21 19:16:37 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-09-21 19:16:37 +0100 |
commit | 8dd0d7abaad97d9845f66f7ff814256dd577e072 (patch) | |
tree | dd9fede82f987bec2e258246292b86fab0afd011 /src/libserver | |
parent | 0050cedd31961425907fc655056ad36bb73b61fe (diff) | |
download | rspamd-8dd0d7abaad97d9845f66f7ff814256dd577e072.tar.gz rspamd-8dd0d7abaad97d9845f66f7ff814256dd577e072.zip |
[Fix] Select the correct signature when doing simple canon
Issue: #1841
Closes: #1841
MFH: rspamd-1.6
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/dkim.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c index ecbddb89a..29cb30fb9 100644 --- a/src/libserver/dkim.c +++ b/src/libserver/dkim.c @@ -93,6 +93,7 @@ enum rspamd_dkim_key_type { struct rspamd_dkim_common_ctx { rspamd_mempool_t *pool; + guint64 sig_hash; gsize len; gint header_canon_type; gint body_canon_type; @@ -746,6 +747,8 @@ rspamd_create_dkim_context (const gchar *sig, p = sig; c = sig; end = p + strlen (p); + ctx->common.sig_hash = rspamd_cryptobox_fast_hash (sig, end - sig, + rspamd_hash_seed ()); while (p <= end) { switch (state) { @@ -2099,9 +2102,10 @@ rspamd_dkim_canonize_header (struct rspamd_dkim_common_ctx *ctx, } PTR_ARRAY_FOREACH (ar, i, rh) { - if (rspamd_substring_search (rh->raw_value, - rh->raw_len, dkim_domain, - strlen (dkim_domain)) != -1) { + guint64 th = rspamd_cryptobox_fast_hash (rh->decoded, + strlen (rh->decoded), rspamd_hash_seed ()); + + if (th == ctx->sig_hash) { rspamd_dkim_signature_update (ctx, rh->raw_value, rh->raw_len); break; |