9b9f54
From 371686fb68eff02020ddd80a702c39f31a849b8e Mon Sep 17 00:00:00 2001
9b9f54
From: David Woodhouse <David.Woodhouse@intel.com>
9b9f54
Date: Wed, 21 Sep 2016 08:20:29 +0100
9b9f54
Subject: [PATCH] Issue #239: Crash on module unload with OpenSSL
9b9f54
9b9f54
We use CRYPTO_set_id_callback() to set a callback, but we don't ever
9b9f54
remove it again on unload. So OpenSSL crashes the next time it needs a
9b9f54
thread-id.
9b9f54
9b9f54
CRYPTO_set_id_callback() has been deprecated since OpenSSL 1.0.0, the
9b9f54
oldest we support. And redundant too, since OpenSSL has fallbacks which
9b9f54
include the address of errno. Which is going to work on any platform
9b9f54
with pthreads... and we were only calling CRYPTO_set_id_callback() on
9b9f54
platforms with pthreads.
9b9f54
9b9f54
So just rip it out.
9b9f54
---
9b9f54
 src/lib/crypto/OSSLCryptoFactory.cpp | 14 --------------
9b9f54
 1 file changed, 14 deletions(-)
9b9f54
9b9f54
diff --git a/src/lib/crypto/OSSLCryptoFactory.cpp b/src/lib/crypto/OSSLCryptoFactory.cpp
9b9f54
index 3aa8dcd..fc059ae 100644
9b9f54
--- a/src/lib/crypto/OSSLCryptoFactory.cpp
9b9f54
+++ b/src/lib/crypto/OSSLCryptoFactory.cpp
9b9f54
@@ -55,9 +55,6 @@
9b9f54
 #include "OSSLGOST.h"
9b9f54
 #endif
9b9f54
 
9b9f54
-#ifdef HAVE_PTHREAD_H
9b9f54
-#include <pthread.h>
9b9f54
-#endif
9b9f54
 #include <algorithm>
9b9f54
 #include <string.h>
9b9f54
 #include <openssl/ssl.h>
9b9f54
@@ -72,14 +69,6 @@
9b9f54
 bool OSSLCryptoFactory::FipsSelfTestStatus = false;
9b9f54
 #endif
9b9f54
 
9b9f54
-// Thread ID callback
9b9f54
-#ifdef HAVE_PTHREAD_H
9b9f54
-static unsigned long id_callback()
9b9f54
-{
9b9f54
-	return (unsigned long) pthread_self();
9b9f54
-}
9b9f54
-#endif
9b9f54
-
9b9f54
 static unsigned nlocks;
9b9f54
 static Mutex** locks;
9b9f54
 
9b9f54
@@ -116,9 +105,6 @@ OSSLCryptoFactory::OSSLCryptoFactory()
9b9f54
 	{
9b9f54
 		locks[i] = MutexFactory::i()->getMutex();
9b9f54
 	}
9b9f54
-#ifdef HAVE_PTHREAD_H
9b9f54
-	CRYPTO_set_id_callback(id_callback);
9b9f54
-#endif
9b9f54
 	CRYPTO_set_locking_callback(lock_callback);
9b9f54
 
9b9f54
 #ifdef WITH_FIPS
9b9f54
-- 
9b9f54
2.25.1
9b9f54