- if (!qu->cname_dgram) { /* Ignore second and subsequent CNAMEs */
- qu->cname_dgram= adns__alloc_mine(qu,dglen);
- if (!qu->cname_dgram) return;
+ if (qu->flags & adns_qf_cname_forbid) {
+ adns__query_fail(qu,adns_s_prohibitedcname);
+ return;
+ } else if (qu->cname_dgram) { /* Ignore second and subsequent CNAME(s) */
+ adns__debug(ads,serv,qu,"allegedly canonical name %s is actually alias for %s",
+ qu->answer->cname,
+ adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rdstart));
+ adns__query_fail(qu,adns_s_prohibitedcname);
+ return;
+ } 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 {