[glib-networking] gnutls: always strip trailing . from SNI hostname



commit 50b76e43e03086d82b7cc28d3f77400c141920d2
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Dec 21 15:47:04 2019 -0600

    gnutls: always strip trailing . from SNI hostname
    
    Everything breaks if this ends in a period. I previously fixed one of
    the two calls, but didn't realize there was a second call.

 tls/gnutls/gtlsclientconnection-gnutls.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/tls/gnutls/gtlsclientconnection-gnutls.c b/tls/gnutls/gtlsclientconnection-gnutls.c
index 1d2ba78..734ad75 100644
--- a/tls/gnutls/gtlsclientconnection-gnutls.c
+++ b/tls/gnutls/gtlsclientconnection-gnutls.c
@@ -353,8 +353,15 @@ g_tls_client_connection_gnutls_set_property (GObject      *object,
            * initialization */
           if (session)
             {
+              gchar *normalized_hostname = g_strdup (hostname);
+
+              if (hostname[strlen (hostname) - 1] == '.')
+                normalized_hostname[strlen (hostname) - 1] = '\0';
+
               gnutls_server_name_set (session, GNUTLS_NAME_DNS,
-                                      hostname, strlen (hostname));
+                                      normalized_hostname, strlen (normalized_hostname));
+
+              g_free (normalized_hostname);
             }
         }
       break;


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