From: Mark Andrews Date: Wed, 7 Jul 2021 05:47:59 +0000 (+1000) Subject: Fix unchecked return of isc_rwlock_lock and isc_rwlock_unlock X-Git-Tag: v9.17.17~35^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ce5207699d9c37c46d29d91c295947443c425861;p=thirdparty%2Fbind9.git Fix unchecked return of isc_rwlock_lock and isc_rwlock_unlock (cherry picked from commit bcaf23dd2799e30cfee1b5d39dec0fbc8e5f7193) --- diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index e321295684d..6cea5138d21 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -126,7 +126,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; @@ -385,9 +385,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); } diff --git a/lib/isc/rwlock.c b/lib/isc/rwlock.c index 7984a630422..9f732b3aaa7 100644 --- a/lib/isc/rwlock.c +++ b/lib/isc/rwlock.c @@ -112,9 +112,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); }