From 95dec56da1dcd50431d253cd7ed29e51e9ec8637 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 9 Nov 2015 13:32:14 +0000 Subject: [PATCH] Fix spf redirects. --- src/libserver/spf.c | 11 +++++++---- src/libserver/spf.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libserver/spf.c b/src/libserver/spf.c index 433f8f927..36b513707 100644 --- a/src/libserver/spf.c +++ b/src/libserver/spf.c @@ -249,7 +249,7 @@ static void rspamd_spf_process_reference (struct spf_resolved *target, struct spf_addr *addr, struct spf_record *rec, gboolean top) { - struct spf_resolved_element *elt; + struct spf_resolved_element *elt, *relt; struct spf_addr *cur = NULL, taddr; guint i; @@ -267,7 +267,7 @@ rspamd_spf_process_reference (struct spf_resolved *target, for (i = 0; i < elt->elts->len; i++) { cur = g_ptr_array_index (elt->elts, i); - if (cur->flags & RSPAMD_SPF_FLAG_PARSED) { + if (cur->flags & RSPAMD_SPF_FLAG_REDIRECT) { break; } } @@ -281,7 +281,10 @@ rspamd_spf_process_reference (struct spf_resolved *target, g_assert (cur->flags & RSPAMD_SPF_FLAG_REFRENCE); g_assert (cur->m.idx < rec->resolved->len); - elt = g_ptr_array_index (rec->resolved, cur->m.idx); + relt = g_ptr_array_index (rec->resolved, cur->m.idx); + msg_debug_spf ("domain %s is redirected to %s", elt->cur_domain, + relt->cur_domain); + elt = relt; } for (i = 0; i < elt->elts->len; i++) { @@ -1065,7 +1068,7 @@ parse_spf_redirect (struct spf_record *rec, cb = rspamd_mempool_alloc (task->task_pool, sizeof (struct spf_dns_cb)); /* Set reference */ - addr->flags |= RSPAMD_SPF_FLAG_REFRENCE; + addr->flags |= RSPAMD_SPF_FLAG_REFRENCE | RSPAMD_SPF_FLAG_REDIRECT; addr->m.idx = rec->resolved->len; cb->rec = rec; diff --git a/src/libserver/spf.h b/src/libserver/spf.h index cdb7a0434..9aa439905 100644 --- a/src/libserver/spf.h +++ b/src/libserver/spf.h @@ -34,6 +34,7 @@ typedef enum spf_action_e { #define RSPAMD_SPF_FLAG_PARSED (1 << 3) #define RSPAMD_SPF_FLAG_VALID (1 << 4) #define RSPAMD_SPF_FLAG_REFRENCE (1 << 5) +#define RSPAMD_SPF_FLAG_REDIRECT (1 << 6) struct spf_addr { guchar addr6[sizeof (struct in6_addr)]; -- 2.39.5