]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Restore the disassociate call to before the fetch
authorMark Andrews <marka@isc.org>
Thu, 29 Feb 2024 03:00:58 +0000 (14:00 +1100)
committerMark Andrews <marka@isc.org>
Tue, 5 Mar 2024 23:08:30 +0000 (10:08 +1100)
[GL #3709] reordered the dns_rdataset_disassociate call to after
the dns_resolver_createfetch call resulting in qctx->nsrrset still
being associated when dns_resolver_createfetch is called in
resume_dslookup (7e4e125e).  Revert that part of the change and add
comments as to why the multiple dns_rdataset_disassociate calls are
where they are.

lib/dns/resolver.c

index 635b9ea0190ddb85427484eccad43514ce20d310..0570ff45a2ba37cb0a897d8e0b41e85137c8cb8b 100644 (file)
@@ -6964,7 +6964,7 @@ resume_dslookup(void *arg) {
        }
 
        /* Preserve data from resp before freeing it. */
-       frdataset = resp->rdataset;
+       frdataset = resp->rdataset; /* a.k.a. fctx->nsrrset */
        result = resp->result;
        isc_mem_putanddetach(&resp->mctx, resp, sizeof(*resp));
 
@@ -6988,6 +6988,13 @@ resume_dslookup(void *arg) {
                }
                dns_rdataset_clone(frdataset, &fctx->nameservers);
 
+               /*
+                * Disassociate now the NS's are saved.
+                */
+               if (dns_rdataset_isassociated(frdataset)) {
+                       dns_rdataset_disassociate(frdataset);
+               }
+
                fctx->ns_ttl = fctx->nameservers.ttl;
                fctx->ns_ttl_ok = true;
                log_ns_ttl(fctx, "resume_dslookup");
@@ -7005,10 +7012,21 @@ resume_dslookup(void *arg) {
 
        case ISC_R_SHUTTINGDOWN:
        case ISC_R_CANCELED:
-               /* Don't try anymore */
+               /* Don't try anymore. */
+               /* Can't be done in cleanup. */
+               if (dns_rdataset_isassociated(frdataset)) {
+                       dns_rdataset_disassociate(frdataset);
+               }
                goto cleanup;
 
        default:
+               /*
+                * Disassociate for the next dns_resolver_createfetch call.
+                */
+               if (dns_rdataset_isassociated(frdataset)) {
+                       dns_rdataset_disassociate(frdataset);
+               }
+
                /*
                 * If the chain of resume_dslookup() invocations managed to
                 * chop off enough labels from the original DS owner name to
@@ -7058,10 +7076,6 @@ resume_dslookup(void *arg) {
 cleanup:
        dns_resolver_destroyfetch(&fetch);
 
-       if (dns_rdataset_isassociated(frdataset)) {
-               dns_rdataset_disassociate(frdataset);
-       }
-
        if (result != ISC_R_SUCCESS) {
                /* An error occurred, tear down whole fctx */
                fctx_done_unref(fctx, result);