From: Evan Hunt Date: Tue, 5 Oct 2021 00:07:22 +0000 (-0700) Subject: increment fctx references while waiting for validator X-Git-Tag: v9.17.19~9^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=436424c458f9f199e300c7834711d5e62dc37692;p=thirdparty%2Fbind9.git increment fctx references while waiting for validator We need to ensure the fctx isn't freed while the validator is pending. --- diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 02c09aad344..828f732c474 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -916,6 +916,7 @@ valcreate(fetchctx_t *fctx, dns_message_t *message, dns_adbaddrinfo_t *addrinfo, INSIST(fctx->validator == NULL); fctx->validator = validator; } + fctx_increference(fctx); ISC_LIST_APPEND(fctx->validators, validator, link); } else { dns_message_detach(&valarg->message); @@ -5222,6 +5223,8 @@ validated(isc_task_t *task, isc_event_t *event) { LOCK(&res->buckets[bucketnum].lock); sentresponse = ((fctx->options & DNS_FETCHOPT_NOVALIDATE) != 0); + RUNTIME_CHECK(!fctx_decreference(fctx)); + /* * If shutting down, ignore the results. Check to see if we're * done waiting for validator completions and ADB pending @@ -5334,8 +5337,10 @@ validated(isc_task_t *task, isc_event_t *event) { result = fctx->vresult; add_bad(fctx, message, addrinfo, result, badns_validation); isc_event_free(&event); + UNLOCK(&res->buckets[bucketnum].lock); INSIST(fctx->validator == NULL); + fctx->validator = ISC_LIST_HEAD(fctx->validators); if (fctx->validator != NULL) { dns_validator_send(fctx->validator);