diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-09-24 13:16:01 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-09-24 13:16:01 +0100 |
commit | 50a508f71363db1ab9db5463b754a54387d2fcf2 (patch) | |
tree | f73b9334432dd0b902a31d30f66d95e8b64bd450 /src | |
parent | 215a57a76656098ba81f44d7e7033f4de0badf78 (diff) | |
download | rspamd-50a508f71363db1ab9db5463b754a54387d2fcf2.tar.gz rspamd-50a508f71363db1ab9db5463b754a54387d2fcf2.zip |
[Fix] Fix issues with the recent SPF changes
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/spf.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/libserver/spf.c b/src/libserver/spf.c index 2459ee7cc..c0ca38e15 100644 --- a/src/libserver/spf.c +++ b/src/libserver/spf.c @@ -389,7 +389,11 @@ rspamd_spf_record_flatten (struct spf_record *rec) } } else { - return rec; + res = g_slice_alloc0 (sizeof (*res)); + res->elts = g_array_new (FALSE, FALSE, sizeof (struct spf_addr)); + res->domain = g_strdup (rec->sender_domain); + res->ttl = rec->ttl; + REF_INIT_RETAIN (res, rspamd_flatten_record_dtor); } return res; @@ -1787,7 +1791,8 @@ static void spf_dns_callback (struct rdns_reply *reply, gpointer arg) { struct spf_record *rec = arg; - struct spf_resolved_element *resolved; + struct spf_resolved_element *resolved = NULL; + struct spf_addr *addr; rec->requests_inflight--; @@ -1801,21 +1806,21 @@ spf_dns_callback (struct rdns_reply *reply, gpointer arg) else if ((reply->code == RDNS_RC_NOREC || reply->code == RDNS_RC_NXDOMAIN) && rec->dns_requests == 0) { resolved = rspamd_spf_new_addr_list (rec, rec->sender_domain); - struct spf_addr *addr; addr = g_slice_alloc0 (sizeof(*addr)); addr->flags = 0; addr->flags |= RSPAMD_SPF_FLAG_NA; g_ptr_array_insert (resolved->elts, 0, addr); } - if (!spf_process_txt_record (rec, resolved, reply)) { - if (rec->dns_requests == 0) { - resolved = g_ptr_array_index(rec->resolved, 0); - struct spf_addr *addr; - addr = g_slice_alloc0 (sizeof(*addr)); - addr->flags = 0; - addr->flags |= RSPAMD_SPF_FLAG_NA; - g_ptr_array_insert (resolved->elts, 0, addr); + if (resolved) { + if (!spf_process_txt_record (rec, resolved, reply)) { + if (rec->dns_requests == 0) { + resolved = g_ptr_array_index(rec->resolved, 0); + addr = g_slice_alloc0 (sizeof(*addr)); + addr->flags = 0; + addr->flags |= RSPAMD_SPF_FLAG_NA; + g_ptr_array_insert (resolved->elts, 0, addr); + } } } |