openca / libpki

Easy-to-use high-level library for PKI-enabled applications
Other
50 stars 34 forks source link

Deadlock in PKI_RWLOCK_write_lock #1

Closed a157634 closed 10 years ago

a157634 commented 10 years ago

PKI_RWLOCK_write_lock() creates two locks on the variable lock_mutex, but only one lock is released. Also the n_writers variable is modified incorrectly. This patch should fix this issue: diff -ur libpki-0.8.7/src/pki_threads_vars.c libpki-0.8.7_patched/src/pki_threads_vars.c --- libpki-0.8.7/src/pki_threads_vars.c 2014-08-05 19:55:39.000000000 +0200 +++ libpki-0.8.7_patched/src/pki_threads_vars.c 2014-08-14 22:05:40.505266425 +0200 @@ -124,9 +124,9 @@ pthread_mutex_unlock(&l->lock_mutex);

pthread_mutex_lock(&l->data_mutex);

opencrypto commented 10 years ago

Thanks! I just applied the patch. Although this applies only to environments where the RWLOCK is not available in pthread (not many) it is important we support that correctly! Thanks again and please let me know if the lock now performs correctly in your environment.

a157634 commented 10 years ago

Yes, it works as expected.