2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Ensure that cache pointer is set to NULL by isc_tlsctx_cache_detach()

If the reference count was higher than 1, detaching a tlsctx cache
didn't clear the pointer, which could trigger an assertion later.
This commit is contained in:
Evan Hunt
2022-01-04 11:48:25 -08:00
parent a1db2347d4
commit f5074c0c8e

View File

@@ -963,17 +963,23 @@ tlsctx_cache_entry_destroy(isc_mem_t *mctx, isc_tlsctx_cache_entry_t *entry) {
void
isc_tlsctx_cache_detach(isc_tlsctx_cache_t **pcache) {
isc_tlsctx_cache_t *cache;
isc_tlsctx_cache_t *cache = NULL;
isc_ht_iter_t *it = NULL;
isc_result_t result;
REQUIRE(pcache != NULL);
cache = *pcache;
*pcache = NULL;
REQUIRE(VALID_TLSCTX_CACHE(cache));
if (isc_refcount_decrement(&cache->references) > 1) {
return;
}
cache->magic = 0;
RUNTIME_CHECK(isc_ht_iter_create(cache->data, &it) == ISC_R_SUCCESS);
for (result = isc_ht_iter_first(it); result == ISC_R_SUCCESS;
result = isc_ht_iter_delcurrent_next(it))
@@ -982,13 +988,12 @@ isc_tlsctx_cache_detach(isc_tlsctx_cache_t **pcache) {
isc_ht_iter_current(it, (void **)&entry);
tlsctx_cache_entry_destroy(cache->mctx, entry);
}
isc_ht_iter_destroy(&it);
isc_ht_destroy(&cache->data);
isc_rwlock_destroy(&cache->rwlock);
cache->magic = 0;
isc_mem_putanddetach(&cache->mctx, cache, sizeof(*cache));
*pcache = NULL;
}
isc_result_t