From: Evan Hunt Date: Wed, 26 Feb 2025 22:56:46 +0000 (-0800) Subject: fix the fetchresponse result for CNAME/DNAME X-Git-Tag: ondrej/lock-free-qpzone-reads-v1~16^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ebeb60174f3074f96b7c00dcda852a5bd61bad6;p=thirdparty%2Fbind9.git fix the fetchresponse result for CNAME/DNAME the fix in commit 1edbbc32b4 was incomplete; the wrong event result could also be set in cache_name() and validated(). --- diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 1bbd455af0a..7693c082527 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -5659,11 +5659,24 @@ answer_response: * Negative results must be indicated in val->result. */ INSIST(hresp->rdataset != NULL); - if (dns_rdataset_isassociated(hresp->rdataset) && - NEGATIVE(hresp->rdataset)) - { - INSIST(eresult == DNS_R_NCACHENXDOMAIN || - eresult == DNS_R_NCACHENXRRSET); + if (dns_rdataset_isassociated(hresp->rdataset)) { + if (NEGATIVE(hresp->rdataset)) { + INSIST(eresult == DNS_R_NCACHENXDOMAIN || + eresult == DNS_R_NCACHENXRRSET); + } else if (eresult == ISC_R_SUCCESS && + hresp->rdataset->type != fctx->type) + { + switch (hresp->rdataset->type) { + case dns_rdatatype_cname: + eresult = DNS_R_CNAME; + break; + case dns_rdatatype_dname: + eresult = DNS_R_DNAME; + break; + default: + break; + } + } } hresp->result = eresult; @@ -6313,11 +6326,25 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, dns_message_t *message, * Negative results must be indicated in * resp->result. */ - if (dns_rdataset_isassociated(resp->rdataset) && - NEGATIVE(resp->rdataset)) - { - INSIST(eresult == DNS_R_NCACHENXDOMAIN || - eresult == DNS_R_NCACHENXRRSET); + if (dns_rdataset_isassociated(resp->rdataset)) { + if (NEGATIVE(resp->rdataset)) { + INSIST(eresult == + DNS_R_NCACHENXDOMAIN || + eresult == DNS_R_NCACHENXRRSET); + } else if (eresult == ISC_R_SUCCESS && + resp->rdataset->type != fctx->type) + { + switch (resp->rdataset->type) { + case dns_rdatatype_cname: + eresult = DNS_R_CNAME; + break; + case dns_rdatatype_dname: + eresult = DNS_R_DNAME; + break; + default: + break; + } + } } resp->result = eresult; if (adbp != NULL && *adbp != NULL) {