X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/adns/blobdiff_plain/c84b735597e27c7be9f23ac28e3f3c70b5a505ce..0872e2895aa60a446cc7d2b2b2b71e0784ade074:/src/reply.c?ds=inline diff --git a/src/reply.c b/src/reply.c index 8da0bf2..61fee52 100644 --- a/src/reply.c +++ b/src/reply.c @@ -21,7 +21,6 @@ */ #include -#include #include "internal.h" @@ -167,7 +166,14 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, if (qu->flags & adns_qf_cname_forbid) { adns__query_fail(qu,adns_s_prohibitedcname); return; - } else if (!qu->cname_dgram) { /* Ignore second and subsequent CNAMEs */ + } else if (qu->cname_dgram) { /* Ignore second and subsequent CNAME(s) */ + adns__debug(ads,serv,qu,"ignoring duplicate CNAME (%s, as well as %s)", + adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rdstart), + qu->answer->cname); + } else if (wantedrrs) { /* Ignore CNAME(s) after RR(s). */ + adns__debug(ads,serv,qu,"ignoring CNAME (to %s) coexisting with RR", + adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rdstart)); + } else { qu->cname_begin= rdstart; qu->cname_dglen= dglen; st= adns__parse_domain(ads,serv,qu, &qu->vb, @@ -190,10 +196,6 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, * TCP. If there is no truncation we can use the whole answer if * it contains the relevant info. */ - } else { - adns__debug(ads,serv,qu,"ignoring duplicate CNAME (%s, as well as %s)", - adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rdstart), - qu->answer->cname); } } else if (rrtype == (qu->typei->type & adns__rrt_typemask)) { wantedrrs++;