summaryrefslogtreecommitdiffstats
path: root/src/idevice.c
diff options
context:
space:
mode:
authorGravatar Christophe Fergeau2017-04-26 11:36:54 +0200
committerGravatar Christophe Fergeau2017-04-26 15:21:02 +0200
commitf635812ccc9b2eb63f5bc2b494d7fdae9c9e1ef3 (patch)
treec894be5673a33c1e004bbddb7b92226e0583a40d /src/idevice.c
parent02a0e03e24bc96bba2e5ea2438c30baf803fd137 (diff)
downloadlibimobiledevice-f635812ccc9b2eb63f5bc2b494d7fdae9c9e1ef3.tar.gz
libimobiledevice-f635812ccc9b2eb63f5bc2b494d7fdae9c9e1ef3.tar.bz2
Don't use ERR_remove_thread_state() with OpenSSL 1.1.0
It's deprecated and causes compile-time warnings. We don't want to fallback to ERR_remove_state() either as it's similarly deprecated. This commit adds a helper functions to hide the #ifdef mess between the various openssl versions. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Diffstat (limited to 'src/idevice.c')
-rw-r--r--src/idevice.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/idevice.c b/src/idevice.c
index d1f13cb..1c43269 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -37,10 +37,7 @@
#ifdef HAVE_OPENSSL
#include <openssl/err.h>
#include <openssl/ssl.h>
-#if OPENSSL_VERSION_NUMBER >= 0x10000001L
-/* since OpenSSL 1.0.0-beta1 */
-#define HAVE_ERR_REMOVE_THREAD_STATE 1
-#endif
+
#else
#include <gnutls/gnutls.h>
#endif
@@ -59,6 +56,19 @@ static void SSL_COMP_free_compression_methods(void)
}
#endif
+static void openssl_remove_thread_state(void)
+{
+/* ERR_remove_thread_state() is available since OpenSSL 1.0.0-beta1, but
+ * deprecated in OpenSSL 1.1.0 */
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER >= 0x10000001L
+ ERR_remove_thread_state(NULL);
+#else
+ ERR_remove_state(0);
+#endif
+#endif
+}
+
static mutex_t *mutex_buf = NULL;
static void locking_function(int mode, int n, const char* file, int line)
{
@@ -109,11 +119,7 @@ static void internal_idevice_deinit(void)
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
SSL_COMP_free_compression_methods();
-#ifdef HAVE_ERR_REMOVE_THREAD_STATE
- ERR_remove_thread_state(NULL);
-#else
- ERR_remove_state(0);
-#endif
+ openssl_remove_thread_state();
#else
gnutls_global_deinit();
#endif
@@ -764,11 +770,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne
debug_info("SSL mode enabled, cipher: %s", SSL_get_cipher(ssl));
}
/* required for proper multi-thread clean up to prevent leaks */
-#ifdef HAVE_ERR_REMOVE_THREAD_STATE
- ERR_remove_thread_state(NULL);
-#else
- ERR_remove_state(0);
-#endif
+ openssl_remove_thread_state();
#else
ssl_data_t ssl_data_loc = (ssl_data_t)malloc(sizeof(struct ssl_data_private));