[glib-networking: 84/129] tls: do not leak the ec key



commit 8b9f4076a3a5932aae229c7b8c517840ad2abcf6
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date:   Mon Oct 30 16:23:18 2017 +0100

    tls: do not leak the ec key

 tls/openssl/gtlsserverconnection-openssl.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/tls/openssl/gtlsserverconnection-openssl.c b/tls/openssl/gtlsserverconnection-openssl.c
index 88229ca..a4d7448 100644
--- a/tls/openssl/gtlsserverconnection-openssl.c
+++ b/tls/openssl/gtlsserverconnection-openssl.c
@@ -329,8 +329,16 @@ g_tls_server_connection_openssl_initable_init (GInitable       *initable,
 # ifdef SSL_CTX_set_ecdh_auto
   SSL_CTX_set_ecdh_auto (priv->ssl_ctx, 1);
 # else
-  SSL_CTX_set_tmp_ecdh (priv->ssl_ctx,
-                        EC_KEY_new_by_curve_name (NID_X9_62_prime256v1));
+  {
+    EC_KEY *ecdh;
+
+    ecdh = EC_KEY_new_by_curve_name (NID_X9_62_prime256v1);
+    if (ecdh != NULL)
+      {
+        SSL_CTX_set_tmp_ecdh (priv->ssl_ctx, ecdh);
+        EC_KEY_free (ecdh);
+      }
+  }
 # endif
 #endif
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]