From: Mark Andrews Date: Thu, 29 Feb 2024 03:00:58 +0000 (+1100) Subject: Restore the disassociate call to before the fetch X-Git-Tag: v9.19.22~11^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ff55e13e867b030e768d537c83ec84427b44403;p=thirdparty%2Fbind9.git Restore the disassociate call to before the fetch [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. --- diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 635b9ea0190..0570ff45a2b 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -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);