diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-06-08 12:03:33 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-06-08 12:03:33 +0100 |
commit | 906e7cfaaae91d19b2034cade2903282d066e876 (patch) | |
tree | bd71bd344b096e24ba74d1926699aa88082af717 /contrib/librdns/util.c | |
parent | 22fa0421cdaed8bf4e151777fd8fc1c09487fa44 (diff) | |
download | rspamd-906e7cfaaae91d19b2034cade2903282d066e876.tar.gz rspamd-906e7cfaaae91d19b2034cade2903282d066e876.zip |
[Feature] Add support of fake DNS records
Diffstat (limited to 'contrib/librdns/util.c')
-rw-r--r-- | contrib/librdns/util.c | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/contrib/librdns/util.c b/contrib/librdns/util.c index b03128983..a4018cbd3 100644 --- a/contrib/librdns/util.c +++ b/contrib/librdns/util.c @@ -353,34 +353,38 @@ rdns_reply_free (struct rdns_reply *rep) { struct rdns_reply_entry *entry, *tmp; - LL_FOREACH_SAFE (rep->entries, entry, tmp) { - switch (entry->type) { - case RDNS_REQUEST_PTR: - free (entry->content.ptr.name); - break; - case RDNS_REQUEST_NS: - free (entry->content.ns.name); - break; - case RDNS_REQUEST_MX: - free (entry->content.mx.name); - break; - case RDNS_REQUEST_TXT: - case RDNS_REQUEST_SPF: - free (entry->content.txt.data); - break; - case RDNS_REQUEST_SRV: - free (entry->content.srv.target); - break; - case RDNS_REQUEST_TLSA: - free (entry->content.tlsa.data); - break; - case RDNS_REQUEST_SOA: - free (entry->content.soa.mname); - free (entry->content.soa.admin); - break; + /* We don't need to free data for faked replies */ + if (!rep->request || rep->request->state != RDNS_REQUEST_FAKE) { + LL_FOREACH_SAFE (rep->entries, entry, tmp) { + switch (entry->type) { + case RDNS_REQUEST_PTR: + free (entry->content.ptr.name); + break; + case RDNS_REQUEST_NS: + free (entry->content.ns.name); + break; + case RDNS_REQUEST_MX: + free (entry->content.mx.name); + break; + case RDNS_REQUEST_TXT: + case RDNS_REQUEST_SPF: + free (entry->content.txt.data); + break; + case RDNS_REQUEST_SRV: + free (entry->content.srv.target); + break; + case RDNS_REQUEST_TLSA: + free (entry->content.tlsa.data); + break; + case RDNS_REQUEST_SOA: + free (entry->content.soa.mname); + free (entry->content.soa.admin); + break; + } + free (entry); } - free (entry); } + free (rep); } @@ -418,7 +422,11 @@ rdns_request_free (struct rdns_request *req) HASH_DEL (req->io->requests, req); req->async_event = NULL; } - + else if (req->state == RDNS_REQUEST_FAKE) { + req->async->del_write (req->async->data, + req->async_event); + req->async_event = NULL; + } } #ifdef TWEETNACL if (req->curve_plugin_data != NULL) { |