[glib-networking/mcatanzaro/handshake-thread-prefix] 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] Add handshake_thread prefix to several functions where it's missing
- Date: Fri, 20 Sep 2019 18:31:12 +0000 (UTC)
commit 9d4e207ce33ee7e5d364c91eb854dcb745e1742e
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 76efab1..b94e4b0 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 384df22..7f87020 100644
--- a/tls/gnutls/gtlsclientconnection-gnutls.c
+++ b/tls/gnutls/gtlsclientconnection-gnutls.c
@@ -69,14 +69,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;
@@ -104,7 +104,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 *
@@ -313,14 +313,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);
@@ -347,14 +347,14 @@ g_tls_client_connection_gnutls_retrieve_function (gnutls_session_t
g_object_notify (G_OBJECT (gnutls), "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)
{
@@ -365,7 +365,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;
}
}
@@ -377,7 +377,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 2ea627b..175dfc7 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 3926029..5bd1825 100644
--- a/tls/openssl/gtlsclientconnection-openssl.c
+++ b/tls/openssl/gtlsclientconnection-openssl.c
@@ -334,9 +334,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;
@@ -351,7 +351,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));
}
@@ -373,7 +373,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;
}
@@ -503,7 +503,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]