mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
2238. [bug] It was possible to trigger a REQUIRE when a
validation was cancelled. [RT #17106]
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: resolver.c,v 1.351 2007/09/06 10:00:19 marka Exp $ */
|
||||
/* $Id: resolver.c,v 1.352 2007/09/14 05:43:05 marka Exp $ */
|
||||
|
||||
/*! \file */
|
||||
|
||||
@@ -195,6 +195,7 @@ struct fetchctx {
|
||||
isc_sockaddrlist_t bad;
|
||||
isc_sockaddrlist_t edns;
|
||||
isc_sockaddrlist_t edns512;
|
||||
dns_validator_t *validator;
|
||||
ISC_LIST(dns_validator_t) validators;
|
||||
dns_db_t * cache;
|
||||
dns_adb_t * adb;
|
||||
@@ -426,9 +427,13 @@ valcreate(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, dns_name_t *name,
|
||||
sigrdataset, fctx->rmessage,
|
||||
valoptions, task, validated, valarg,
|
||||
&validator);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
if ((valoptions & DNS_VALIDATOR_DEFER) == 0) {
|
||||
INSIST(fctx->validator == NULL);
|
||||
fctx->validator = validator;
|
||||
}
|
||||
ISC_LIST_APPEND(fctx->validators, validator, link);
|
||||
else
|
||||
} else
|
||||
isc_mem_put(fctx->res->buckets[fctx->bucketnum].mctx,
|
||||
valarg, sizeof(*valarg));
|
||||
return (result);
|
||||
@@ -3040,6 +3045,7 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
|
||||
ISC_LIST_INIT(fctx->edns);
|
||||
ISC_LIST_INIT(fctx->edns512);
|
||||
ISC_LIST_INIT(fctx->validators);
|
||||
fctx->validator = NULL;
|
||||
fctx->find = NULL;
|
||||
fctx->altfind = NULL;
|
||||
fctx->pending = 0;
|
||||
@@ -3378,7 +3384,7 @@ maybe_destroy(fetchctx_t *fctx) {
|
||||
unsigned int bucketnum;
|
||||
isc_boolean_t bucket_empty = ISC_FALSE;
|
||||
dns_resolver_t *res = fctx->res;
|
||||
dns_validator_t *validator;
|
||||
dns_validator_t *validator, *next_validator;
|
||||
|
||||
REQUIRE(SHUTTINGDOWN(fctx));
|
||||
|
||||
@@ -3386,16 +3392,22 @@ maybe_destroy(fetchctx_t *fctx) {
|
||||
return;
|
||||
|
||||
for (validator = ISC_LIST_HEAD(fctx->validators);
|
||||
validator != NULL;
|
||||
validator = ISC_LIST_HEAD(fctx->validators)) {
|
||||
ISC_LIST_UNLINK(fctx->validators, validator, link);
|
||||
validator != NULL; validator = next_validator) {
|
||||
next_validator = ISC_LIST_NEXT(validator, link);
|
||||
dns_validator_cancel(validator);
|
||||
/*
|
||||
* If this is a active validator wait for the cancel
|
||||
* to complete before calling dns_validator_destroy().
|
||||
*/
|
||||
if (validator == fctx->validator)
|
||||
continue;
|
||||
ISC_LIST_UNLINK(fctx->validators, validator, link);
|
||||
dns_validator_destroy(&validator);
|
||||
}
|
||||
|
||||
bucketnum = fctx->bucketnum;
|
||||
LOCK(&res->buckets[bucketnum].lock);
|
||||
if (fctx->references == 0)
|
||||
if (fctx->references == 0 && ISC_LIST_EMPTY(fctx->validators))
|
||||
bucket_empty = fctx_destroy(fctx);
|
||||
UNLOCK(&res->buckets[bucketnum].lock);
|
||||
|
||||
@@ -3442,6 +3454,7 @@ validated(isc_task_t *task, isc_event_t *event) {
|
||||
FCTXTRACE("received validation completion event");
|
||||
|
||||
ISC_LIST_UNLINK(fctx->validators, vevent->validator, link);
|
||||
fctx->validator = NULL;
|
||||
|
||||
/*
|
||||
* Destroy the validator early so that we can
|
||||
@@ -3527,9 +3540,11 @@ validated(isc_task_t *task, isc_event_t *event) {
|
||||
add_bad(fctx, addrinfo, result);
|
||||
isc_event_free(&event);
|
||||
UNLOCK(&fctx->res->buckets[fctx->bucketnum].lock);
|
||||
if (!ISC_LIST_EMPTY(fctx->validators))
|
||||
dns_validator_send(ISC_LIST_HEAD(fctx->validators));
|
||||
else if (sentresponse)
|
||||
INSIST(fctx->validator == NULL);
|
||||
fctx->validator = ISC_LIST_HEAD(fctx->validators);
|
||||
if (fctx->validator != NULL) {
|
||||
dns_validator_send(fctx->validator);
|
||||
} else if (sentresponse)
|
||||
fctx_done(fctx, result); /* Locks bucket. */
|
||||
else
|
||||
fctx_try(fctx); /* Locks bucket. */
|
||||
|
Reference in New Issue
Block a user