]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
fix the fetchresponse result for CNAME/DNAME
authorEvan Hunt <each@isc.org>
Wed, 26 Feb 2025 22:56:46 +0000 (14:56 -0800)
committerEvan Hunt <each@isc.org>
Thu, 27 Feb 2025 19:00:27 +0000 (19:00 +0000)
the fix in commit 1edbbc32b4 was incomplete; the wrong
event result could also be set in cache_name() and validated().

lib/dns/resolver.c

index 1bbd455af0afbe1366bc3198c681d4cbb473bfe7..7693c082527b22c91ecd83939fd23a231d145969 100644 (file)
@@ -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) {