]> source.dussan.org Git - rspamd.git/commitdiff
Fix spf redirects.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 9 Nov 2015 13:32:14 +0000 (13:32 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 9 Nov 2015 13:32:14 +0000 (13:32 +0000)
src/libserver/spf.c
src/libserver/spf.h

index 433f8f927ba3ac9f4aa3a4da9e4e420e6e9b3d13..36b513707320c337f905b7967307361e29dfd5a7 100644 (file)
@@ -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;
index cdb7a043408fac2d68a8c764a593e0ef10bb9b89..9aa439905a656fb07fede4510bf2deb4a56b3029 100644 (file)
@@ -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)];