openssl: Ensure the thread ID is never zero
authorTobias Brunner <tobias@strongswan.org>
Sat, 30 Jun 2012 08:05:41 +0000 (10:05 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Jul 2012 10:02:57 +0000 (12:02 +0200)
This might otherwise cause problems because OpenSSL tries to lock
mutexes recursively if it assumes the lock is held by a different
thread e.g. during FIPS initialization.

src/libstrongswan/plugins/openssl/openssl_plugin.c

index 5a11412..7daa92b 100644 (file)
@@ -129,7 +129,9 @@ static void destroy_function(struct CRYPTO_dynlock_value *lock,
  */
 static unsigned long id_function(void)
 {
-       return (unsigned long)thread_current_id();
+       /* ensure the thread ID is never zero, otherwise OpenSSL might try to
+        * acquire locks recursively */
+       return 1 + (unsigned long)thread_current_id();
 }
 
 /**