summaryrefslogtreecommitdiffstats
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
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>
-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 @@
37#ifdef HAVE_OPENSSL 37#ifdef HAVE_OPENSSL
38#include <openssl/err.h> 38#include <openssl/err.h>
39#include <openssl/ssl.h> 39#include <openssl/ssl.h>
40#if OPENSSL_VERSION_NUMBER >= 0x10000001L 40
41/* since OpenSSL 1.0.0-beta1 */
42#define HAVE_ERR_REMOVE_THREAD_STATE 1
43#endif
44#else 41#else
45#include <gnutls/gnutls.h> 42#include <gnutls/gnutls.h>
46#endif 43#endif
@@ -59,6 +56,19 @@ static void SSL_COMP_free_compression_methods(void)
59} 56}
60#endif 57#endif
61 58
59static void openssl_remove_thread_state(void)
60{
61/* ERR_remove_thread_state() is available since OpenSSL 1.0.0-beta1, but
62 * deprecated in OpenSSL 1.1.0 */
63#if OPENSSL_VERSION_NUMBER < 0x10100000L
64#if OPENSSL_VERSION_NUMBER >= 0x10000001L
65 ERR_remove_thread_state(NULL);
66#else
67 ERR_remove_state(0);
68#endif
69#endif
70}
71
62static mutex_t *mutex_buf = NULL; 72static mutex_t *mutex_buf = NULL;
63static void locking_function(int mode, int n, const char* file, int line) 73static void locking_function(int mode, int n, const char* file, int line)
64{ 74{
@@ -109,11 +119,7 @@ static void internal_idevice_deinit(void)
109 EVP_cleanup(); 119 EVP_cleanup();
110 CRYPTO_cleanup_all_ex_data(); 120 CRYPTO_cleanup_all_ex_data();
111 SSL_COMP_free_compression_methods(); 121 SSL_COMP_free_compression_methods();
112#ifdef HAVE_ERR_REMOVE_THREAD_STATE 122 openssl_remove_thread_state();
113 ERR_remove_thread_state(NULL);
114#else
115 ERR_remove_state(0);
116#endif
117#else 123#else
118 gnutls_global_deinit(); 124 gnutls_global_deinit();
119#endif 125#endif
@@ -764,11 +770,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne
764 debug_info("SSL mode enabled, cipher: %s", SSL_get_cipher(ssl)); 770 debug_info("SSL mode enabled, cipher: %s", SSL_get_cipher(ssl));
765 } 771 }
766 /* required for proper multi-thread clean up to prevent leaks */ 772 /* required for proper multi-thread clean up to prevent leaks */
767#ifdef HAVE_ERR_REMOVE_THREAD_STATE 773 openssl_remove_thread_state();
768 ERR_remove_thread_state(NULL);
769#else
770 ERR_remove_state(0);
771#endif
772#else 774#else
773 ssl_data_t ssl_data_loc = (ssl_data_t)malloc(sizeof(struct ssl_data_private)); 775 ssl_data_t ssl_data_loc = (ssl_data_t)malloc(sizeof(struct ssl_data_private));
774 776