[glib-networking: 88/129] Only initialize data_index once
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking: 88/129] Only initialize data_index once
- Date: Sat, 2 Feb 2019 22:50:47 +0000 (UTC)
commit 0fab80ec648ef38e11856384c0b3f6ed802150fa
Author: Anders Skoglund <public andsk se>
Date: Tue Dec 19 11:12:57 2017 +0100
Only initialize data_index once
Add a check so that g_tls_client_connection_openssl_initable_init only
initialize the global data_index variable on the first call. If it is
initialized multiple times it can cause an error in retrieve_certificate
where it uses the index to retrieve stored data.
https://bugzilla.gnome.org/show_bug.cgi?id=791730
tls/openssl/gtlsclientconnection-openssl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/tls/openssl/gtlsclientconnection-openssl.c b/tls/openssl/gtlsclientconnection-openssl.c
index 89c6f24..428cdf4 100644
--- a/tls/openssl/gtlsclientconnection-openssl.c
+++ b/tls/openssl/gtlsclientconnection-openssl.c
@@ -339,7 +339,7 @@ g_tls_client_connection_openssl_client_connection_interface_init (GTlsClientConn
iface->copy_session_state = g_tls_client_connection_openssl_copy_session_state;
}
-static int data_index;
+static int data_index = -1;
static int
retrieve_certificate (SSL *ssl,
@@ -494,7 +494,9 @@ g_tls_client_connection_openssl_initable_init (GInitable *initable,
return FALSE;
}
- data_index = SSL_get_ex_new_index (0, (void *)"gtlsclientconnection", NULL, NULL, NULL);
+ if (data_index == -1) {
+ data_index = SSL_get_ex_new_index (0, (void *)"gtlsclientconnection", NULL, NULL, NULL);
+ }
SSL_set_ex_data (priv->ssl, data_index, client);
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]