[glib-networking/mcatanzaro/tls1.2] Ensure gnutls_certificate_allocate_credentials() is successful
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/tls1.2] Ensure gnutls_certificate_allocate_credentials() is successful
- Date: Sun, 18 Aug 2019 22:41:25 +0000 (UTC)
commit 7c8eb17c25572f6bb8efb5beee0e33f8b33cf163
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Aug 18 17:37:40 2019 -0500
Ensure gnutls_certificate_allocate_credentials() is successful
This should never happen, and it does never happen in my extensive
testing. But for robustness, we really should check to be sure it's not
happening.
tls/gnutls/gtlsconnection-gnutls.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 4e883a7..d2c7e7e 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -89,9 +89,7 @@ static void
g_tls_connection_gnutls_init (GTlsConnectionGnutls *gnutls)
{
GTlsConnectionGnutlsPrivate *priv = g_tls_connection_gnutls_get_instance_private (gnutls);
- gint unique_id;
-
- gnutls_certificate_allocate_credentials (&priv->creds);
+ int unique_id;
unique_id = g_atomic_int_add (&unique_interaction_id, 1);
priv->interaction_id = g_strdup_printf ("gtls:%d", unique_id);
@@ -198,6 +196,7 @@ g_tls_connection_gnutls_initable_init (GInitable *initable,
gboolean client = G_IS_TLS_CLIENT_CONNECTION (gnutls);
guint flags = client ? GNUTLS_CLIENT : GNUTLS_SERVER;
int status;
+ int ret;
g_object_get (gnutls,
"base-io-stream", &base_io_stream,
@@ -210,6 +209,10 @@ g_tls_connection_gnutls_initable_init (GInitable *initable,
if (base_socket)
flags |= GNUTLS_DATAGRAM;
+ ret = gnutls_certificate_allocate_credentials (&priv->creds);
+ if (ret != GNUTLS_E_SUCCESS)
+ return FALSE;
+
gnutls_init (&priv->session, flags);
gnutls_session_set_ptr (priv->session, gnutls);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]