]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Assert that we successfully obtained a lock
authorMatt Caswell <matt@openssl.org>
Wed, 16 Apr 2025 11:15:51 +0000 (12:15 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 30 Apr 2025 08:56:15 +0000 (10:56 +0200)
We should never fail to obtain a lock, so assert that we are successful

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27408)

(cherry picked from commit 606de509e3828fd2fb65184500e6197c82a0efcf)

crypto/threads_pthread.c

index 750ef201210b7dd539564dd83ca4836013cc211b..44d6ebe0923114dc4b2e5a0091283311dbdaf018 100644 (file)
@@ -624,7 +624,7 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
 __owur int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
 {
 # ifdef USE_RWLOCK
-    if (pthread_rwlock_rdlock(lock) != 0)
+    if (!ossl_assert(pthread_rwlock_rdlock(lock) == 0))
         return 0;
 # else
     if (pthread_mutex_lock(lock) != 0) {
@@ -639,7 +639,7 @@ __owur int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
 __owur int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
 {
 # ifdef USE_RWLOCK
-    if (pthread_rwlock_wrlock(lock) != 0)
+    if (!ossl_assert(pthread_rwlock_wrlock(lock) == 0))
         return 0;
 # else
     if (pthread_mutex_lock(lock) != 0) {