From 9ebeb60174f3074f96b7c00dcda852a5bd61bad6 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Wed, 26 Feb 2025 14:56:46 -0800 Subject: [PATCH] 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(). --- lib/dns/resolver.c | 47 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 1bbd455af0..7693c08252 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) {