[glib-networking/mcatanzaro/handshake-thread-prefix: 4/4] Add handshake_thread prefix to several functions where it's missing
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/handshake-thread-prefix: 4/4] Add handshake_thread prefix to several functions where it's missing
- Date: Sun, 22 Sep 2019 21:26:30 +0000 (UTC)
commit 6f580007b664dabec4a4f2ebc0baba7b631e3b8d
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Fri Sep 20 13:21:00 2019 -0500
Add handshake_thread prefix to several functions where it's missing
This prefix is useful to alert us to the need for extreme care when
writing functions that are used on the handshake thread. It could have
helped to avoid #95, for example.
tls/base/gtlsconnection-base.c | 6 ++--
tls/base/gtlsconnection-base.h | 5 ++--
tls/gnutls/gtlsclientconnection-gnutls.c | 44 +++++++++++++++---------------
tls/gnutls/gtlsconnection-gnutls.c | 8 +++---
tls/gnutls/gtlsconnection-gnutls.h | 8 +++---
tls/gnutls/gtlsserverconnection-gnutls.c | 38 +++++++++++++-------------
tls/openssl/gtlsclientconnection-openssl.c | 12 ++++----
7 files changed, 60 insertions(+), 61 deletions(-)
---
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index e80177e..2638d29 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -2415,12 +2415,10 @@ g_tls_connection_base_get_base_ostream (GTlsConnectionBase *tls)
}
void
-g_tls_connection_base_set_missing_requested_client_certificate (GTlsConnectionBase *tls)
+g_tls_connection_base_handshake_thread_set_missing_requested_client_certificate (GTlsConnectionBase *tls)
{
GTlsConnectionBasePrivate *priv = g_tls_connection_base_get_instance_private (tls);
- /* FIXME: Assert this is only used on the handshake thread. */
-
priv->missing_requested_client_certificate = TRUE;
}
@@ -2489,7 +2487,7 @@ g_tls_connection_base_ever_handshaked (GTlsConnectionBase *tls)
}
gboolean
-g_tls_connection_base_request_certificate (GTlsConnectionBase *tls)
+g_tls_connection_base_handshake_thread_request_certificate (GTlsConnectionBase *tls)
{
GTlsConnectionBasePrivate *priv = g_tls_connection_base_get_instance_private (tls);
GTlsInteractionResult res = G_TLS_INTERACTION_UNHANDLED;
diff --git a/tls/base/gtlsconnection-base.h b/tls/base/gtlsconnection-base.h
index aa56d64..1a3e7d5 100644
--- a/tls/base/gtlsconnection-base.h
+++ b/tls/base/gtlsconnection-base.h
@@ -173,7 +173,7 @@ GIOStream *g_tls_connection_base_get_base_iostream (GTlsCon
GPollableInputStream *g_tls_connection_base_get_base_istream (GTlsConnectionBase *tls);
GPollableOutputStream *g_tls_connection_base_get_base_ostream (GTlsConnectionBase *tls);
-void g_tls_connection_base_set_missing_requested_client_certificate
+void g_tls_connection_base_handshake_thread_set_missing_requested_client_certificate
(GTlsConnectionBase *tls);
GError **g_tls_connection_base_get_read_error (GTlsConnectionBase *tls);
@@ -189,7 +189,8 @@ gboolean g_tls_connection_base_is_handshaking (GTlsCon
gboolean g_tls_connection_base_ever_handshaked (GTlsConnectionBase *tls);
-gboolean g_tls_connection_base_request_certificate (GTlsConnectionBase *tls);
+gboolean g_tls_connection_base_handshake_thread_request_certificate
+ (GTlsConnectionBase *tls);
void g_tls_connection_base_handshake_thread_buffer_application_data
(GTlsConnectionBase *tls,
diff --git a/tls/gnutls/gtlsclientconnection-gnutls.c b/tls/gnutls/gtlsclientconnection-gnutls.c
index 4e2f5b7..c2f116c 100644
--- a/tls/gnutls/gtlsclientconnection-gnutls.c
+++ b/tls/gnutls/gtlsclientconnection-gnutls.c
@@ -70,14 +70,14 @@ static void g_tls_client_connection_gnutls_initable_interface_init (GInitabl
static void g_tls_client_connection_gnutls_client_connection_interface_init (GTlsClientConnectionInterface
*iface);
static void g_tls_client_connection_gnutls_dtls_client_connection_interface_init
(GDtlsClientConnectionInterface *iface);
-static int g_tls_client_connection_gnutls_retrieve_function (gnutls_session_t session,
- const gnutls_datum_t *req_ca_rdn,
- int nreqs,
- const gnutls_pk_algorithm_t *pk_algos,
- int pk_algos_length,
- gnutls_pcert_st **pcert,
- unsigned int *pcert_length,
- gnutls_privkey_t *pkey);
+static int g_tls_client_connection_gnutls_handshake_thread_retrieve_function (gnutls_session_t
session,
+ const gnutls_datum_t
*req_ca_rdn,
+ int
nreqs,
+ const gnutls_pk_algorithm_t
*pk_algos,
+ int
pk_algos_length,
+ gnutls_pcert_st
**pcert,
+ unsigned int
*pcert_length,
+ gnutls_privkey_t
*pkey);
static GInitableIface *g_tls_client_connection_gnutls_parent_initable_iface;
@@ -105,7 +105,7 @@ g_tls_client_connection_gnutls_init (GTlsClientConnectionGnutls *gnutls)
gnutls_certificate_credentials_t creds;
creds = g_tls_connection_gnutls_get_credentials (G_TLS_CONNECTION_GNUTLS (gnutls));
- gnutls_certificate_set_retrieve_function2 (creds, g_tls_client_connection_gnutls_retrieve_function);
+ gnutls_certificate_set_retrieve_function2 (creds,
g_tls_client_connection_gnutls_handshake_thread_retrieve_function);
}
static const gchar *
@@ -314,14 +314,14 @@ g_tls_client_connection_gnutls_set_property (GObject *object,
}
static int
-g_tls_client_connection_gnutls_retrieve_function (gnutls_session_t session,
- const gnutls_datum_t *req_ca_rdn,
- int nreqs,
- const gnutls_pk_algorithm_t *pk_algos,
- int pk_algos_length,
- gnutls_pcert_st **pcert,
- unsigned int *pcert_length,
- gnutls_privkey_t *pkey)
+g_tls_client_connection_gnutls_handshake_thread_retrieve_function (gnutls_session_t session,
+ const gnutls_datum_t *req_ca_rdn,
+ int nreqs,
+ const gnutls_pk_algorithm_t *pk_algos,
+ int
pk_algos_length,
+ gnutls_pcert_st **pcert,
+ unsigned int
*pcert_length,
+ gnutls_privkey_t *pkey)
{
GTlsConnectionBase *tls = gnutls_transport_get_ptr (session);
GTlsClientConnectionGnutls *gnutls = gnutls_transport_get_ptr (session);
@@ -352,14 +352,14 @@ g_tls_client_connection_gnutls_retrieve_function (gnutls_session_t
gnutls->accepted_cas_changed = gnutls->accepted_cas || had_accepted_cas;
clear_gnutls_certificate_copy (gnutls);
- g_tls_connection_gnutls_get_certificate (conn, pcert, pcert_length, pkey);
+ g_tls_connection_gnutls_handshake_thread_get_certificate (conn, pcert, pcert_length, pkey);
if (*pcert_length == 0)
{
g_tls_certificate_gnutls_copy_free (*pcert, *pcert_length, *pkey);
- if (g_tls_connection_base_request_certificate (tls))
- g_tls_connection_gnutls_get_certificate (conn, pcert, pcert_length, pkey);
+ if (g_tls_connection_base_handshake_thread_request_certificate (tls))
+ g_tls_connection_gnutls_handshake_thread_get_certificate (conn, pcert, pcert_length, pkey);
if (*pcert_length == 0)
{
@@ -370,7 +370,7 @@ g_tls_client_connection_gnutls_retrieve_function (gnutls_session_t
* be optional, e.g. if the server is using
* G_TLS_AUTHENTICATION_REQUESTED, not G_TLS_AUTHENTICATION_REQUIRED.
*/
- g_tls_connection_base_set_missing_requested_client_certificate (tls);
+ g_tls_connection_base_handshake_thread_set_missing_requested_client_certificate (tls);
return 0;
}
}
@@ -382,7 +382,7 @@ g_tls_client_connection_gnutls_retrieve_function (gnutls_session_t
/* No private key. GnuTLS expects it to be non-null if pcert_length is
* nonzero, so we have to abort now.
*/
- g_tls_connection_base_set_missing_requested_client_certificate (tls);
+ g_tls_connection_base_handshake_thread_set_missing_requested_client_certificate (tls);
return -1;
}
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index e8f62eb..f5eeb0a 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -281,10 +281,10 @@ g_tls_connection_gnutls_get_session (GTlsConnectionGnutls *gnutls)
}
void
-g_tls_connection_gnutls_get_certificate (GTlsConnectionGnutls *gnutls,
- gnutls_pcert_st **pcert,
- unsigned int *pcert_length,
- gnutls_privkey_t *pkey)
+g_tls_connection_gnutls_handshake_thread_get_certificate (GTlsConnectionGnutls *gnutls,
+ gnutls_pcert_st **pcert,
+ unsigned int *pcert_length,
+ gnutls_privkey_t *pkey)
{
GTlsConnectionGnutlsPrivate *priv = g_tls_connection_gnutls_get_instance_private (gnutls);
GTlsCertificate *cert;
diff --git a/tls/gnutls/gtlsconnection-gnutls.h b/tls/gnutls/gtlsconnection-gnutls.h
index d60f9e3..db3b726 100644
--- a/tls/gnutls/gtlsconnection-gnutls.h
+++ b/tls/gnutls/gtlsconnection-gnutls.h
@@ -47,9 +47,9 @@ gnutls_certificate_credentials_t g_tls_connection_gnutls_get_credentials (GTlsCo
gnutls_session_t g_tls_connection_gnutls_get_session (GTlsConnectionGnutls *connection);
-void g_tls_connection_gnutls_get_certificate (GTlsConnectionGnutls *gnutls,
- gnutls_pcert_st **pcert,
- unsigned int *pcert_length,
- gnutls_privkey_t *pkey);
+void g_tls_connection_gnutls_handshake_thread_get_certificate (GTlsConnectionGnutls *gnutls,
+ gnutls_pcert_st **pcert,
+ unsigned int *pcert_length,
+ gnutls_privkey_t *pkey);
G_END_DECLS
diff --git a/tls/gnutls/gtlsserverconnection-gnutls.c b/tls/gnutls/gtlsserverconnection-gnutls.c
index 561fb77..cb84aaa 100644
--- a/tls/gnutls/gtlsserverconnection-gnutls.c
+++ b/tls/gnutls/gtlsserverconnection-gnutls.c
@@ -55,14 +55,14 @@ static void g_tls_server_connection_gnutls_initable_interface_init (GInitabl
static void g_tls_server_connection_gnutls_server_connection_interface_init (GTlsServerConnectionInterface
*iface);
-static int g_tls_server_connection_gnutls_retrieve_function (gnutls_session_t session,
- const gnutls_datum_t *req_ca_rdn,
- int nreqs,
- const gnutls_pk_algorithm_t *pk_algos,
- int pk_algos_length,
- gnutls_pcert_st **pcert,
- unsigned int *pcert_length,
- gnutls_privkey_t *pkey);
+static int g_tls_server_connection_gnutls_handshake_thread_retrieve_function (gnutls_session_t
session,
+ const gnutls_datum_t
*req_ca_rdn,
+ int
nreqs,
+ const gnutls_pk_algorithm_t
*pk_algos,
+ int
pk_algos_length,
+ gnutls_pcert_st
**pcert,
+ unsigned int
*pcert_length,
+ gnutls_privkey_t
*pkey);
static int g_tls_server_connection_gnutls_db_store (void *user_data,
gnutls_datum_t key,
@@ -99,7 +99,7 @@ g_tls_server_connection_gnutls_init (GTlsServerConnectionGnutls *gnutls)
gnutls_certificate_credentials_t creds;
creds = g_tls_connection_gnutls_get_credentials (G_TLS_CONNECTION_GNUTLS (gnutls));
- gnutls_certificate_set_retrieve_function2 (creds, g_tls_server_connection_gnutls_retrieve_function);
+ gnutls_certificate_set_retrieve_function2 (creds,
g_tls_server_connection_gnutls_handshake_thread_retrieve_function);
}
static void
@@ -180,21 +180,21 @@ g_tls_server_connection_gnutls_set_property (GObject *object,
}
static int
-g_tls_server_connection_gnutls_retrieve_function (gnutls_session_t session,
- const gnutls_datum_t *req_ca_rdn,
- int nreqs,
- const gnutls_pk_algorithm_t *pk_algos,
- int pk_algos_length,
- gnutls_pcert_st **pcert,
- unsigned int *pcert_length,
- gnutls_privkey_t *pkey)
+g_tls_server_connection_gnutls_handshake_thread_retrieve_function (gnutls_session_t session,
+ const gnutls_datum_t *req_ca_rdn,
+ int nreqs,
+ const gnutls_pk_algorithm_t *pk_algos,
+ int
pk_algos_length,
+ gnutls_pcert_st **pcert,
+ unsigned int
*pcert_length,
+ gnutls_privkey_t *pkey)
{
GTlsServerConnectionGnutls *gnutls = G_TLS_SERVER_CONNECTION_GNUTLS (gnutls_transport_get_ptr (session));
clear_gnutls_certificate_copy (gnutls);
- g_tls_connection_gnutls_get_certificate (G_TLS_CONNECTION_GNUTLS (gnutls),
- pcert, pcert_length, pkey);
+ g_tls_connection_gnutls_handshake_thread_get_certificate (G_TLS_CONNECTION_GNUTLS (gnutls),
+ pcert, pcert_length, pkey);
gnutls->pcert = *pcert;
gnutls->pcert_length = *pcert_length;
diff --git a/tls/openssl/gtlsclientconnection-openssl.c b/tls/openssl/gtlsclientconnection-openssl.c
index 06fbd5d..f14401a 100644
--- a/tls/openssl/gtlsclientconnection-openssl.c
+++ b/tls/openssl/gtlsclientconnection-openssl.c
@@ -352,9 +352,9 @@ g_tls_client_connection_openssl_client_connection_interface_init (GTlsClientConn
static int data_index = -1;
static int
-retrieve_certificate (SSL *ssl,
- X509 **x509,
- EVP_PKEY **pkey)
+handshake_thread_retrieve_certificate (SSL *ssl,
+ X509 **x509,
+ EVP_PKEY **pkey)
{
GTlsClientConnectionOpenssl *client;
GTlsConnectionBase *tls;
@@ -371,7 +371,7 @@ retrieve_certificate (SSL *ssl,
cert = g_tls_connection_get_certificate (G_TLS_CONNECTION (client));
if (!cert)
{
- if (g_tls_connection_base_request_certificate (tls))
+ if (g_tls_connection_base_handshake_thread_request_certificate (tls))
cert = g_tls_connection_get_certificate (G_TLS_CONNECTION (client));
}
@@ -393,7 +393,7 @@ retrieve_certificate (SSL *ssl,
return 1;
}
- g_tls_connection_base_set_missing_requested_client_certificate (tls);
+ g_tls_connection_base_handshake_thread_set_missing_requested_client_certificate (tls);
return 0;
}
@@ -523,7 +523,7 @@ g_tls_client_connection_openssl_initable_init (GInitable *initable,
SSL_CTX_add_session (client->ssl_ctx, client->session);
- SSL_CTX_set_client_cert_cb (client->ssl_ctx, retrieve_certificate);
+ SSL_CTX_set_client_cert_cb (client->ssl_ctx, handshake_thread_retrieve_certificate);
#ifdef SSL_CTX_set1_sigalgs_list
set_signature_algorithm_list (client);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]