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

Fix unchecked return of isc_rwlock_lock and isc_rwlock_unlock

This commit is contained in:
Mark Andrews
2021-07-07 15:47:59 +10:00
parent f8a0a1d61f
commit bcaf23dd27
2 changed files with 8 additions and 5 deletions

View File

@@ -124,7 +124,7 @@ struct signer_event {
static dns_dnsseckeylist_t keylist;
static unsigned int keycount = 0;
isc_rwlock_t keylist_lock;
static isc_rwlock_t keylist_lock;
static isc_stdtime_t starttime = 0, endtime = 0, dnskey_endtime = 0, now;
static int cycle = -1;
static int jitter = 0;
@@ -383,9 +383,9 @@ keythatsigned(dns_rdata_rrsig_t *rrsig) {
dst_key_t *pubkey = NULL, *privkey = NULL;
dns_dnsseckey_t *key = NULL;
isc_rwlock_lock(&keylist_lock, isc_rwlocktype_read);
RWLOCK(&keylist_lock, isc_rwlocktype_read);
key = keythatsigned_unlocked(rrsig);
isc_rwlock_unlock(&keylist_lock, isc_rwlocktype_read);
RWUNLOCK(&keylist_lock, isc_rwlocktype_read);
if (key != NULL) {
return (key);
}

View File

@@ -113,9 +113,12 @@ isc_rwlock_tryupgrade(isc_rwlock_t *rwl) {
void
isc_rwlock_downgrade(isc_rwlock_t *rwl) {
isc_result_t result;
atomic_store_release(&rwl->downgrade, true);
isc_rwlock_unlock(rwl, isc_rwlocktype_write);
isc_rwlock_lock(rwl, isc_rwlocktype_read);
result = isc_rwlock_unlock(rwl, isc_rwlocktype_write);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
result = isc_rwlock_lock(rwl, isc_rwlocktype_read);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
atomic_store_release(&rwl->downgrade, false);
}