]> git.eshelyaron.com Git - emacs.git/commitdiff
Only send SNI if the host name is not an IP address
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Wed, 26 Nov 2014 22:11:57 +0000 (23:11 +0100)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Wed, 26 Nov 2014 22:11:57 +0000 (23:11 +0100)
* gnutls.c (gnutls_ip_address_p): New function.
(Fgnutls_boot): Only send SNI if the host name is not an IP address.

src/ChangeLog
src/gnutls.c

index 17e3c5988a67694ea19cdbc2d98a4598ceb4e48b..df704efdf2d477da760c193859f0ba7f7f30f6b7 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-26  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * gnutls.c (gnutls_ip_address_p): New function.
+       (Fgnutls_boot): Only send SNI if the host name is not an IP address.
+
 2014-11-26  Toke Høiland-Jørgensen  <toke@toke.dk>  (tiny change)
 
        * gnutls.c (Fgnutls_boot): Send the server name over (bug#18208).
index 5a4b39f789a12cfe1a401d4f5cd8aa45e098022b..752df3c8edd7c5e7168715564b0ad30ff753cade 100644 (file)
@@ -1095,6 +1095,18 @@ emacs_gnutls_global_init (void)
   return gnutls_make_error (ret);
 }
 
+static bool
+gnutls_ip_address_p (char *string)
+{
+  char c;
+
+  while ((c = *string++) != 0)
+    if (! ((c == '.' || c == ':' || (c >= '0' && c <= '9'))))
+      return false;
+
+  return true;
+}
+
 #if 0
 /* Deinitializes global GnuTLS state.
 See also `gnutls-global-init'.  */
@@ -1418,10 +1430,13 @@ one trustfile (usually a CA bundle).  */)
   if (ret < GNUTLS_E_SUCCESS)
     return gnutls_make_error (ret);
 
-  ret = fn_gnutls_server_name_set (state, GNUTLS_NAME_DNS, c_hostname,
-                                  strlen(c_hostname));
-  if (ret < GNUTLS_E_SUCCESS)
-    return gnutls_make_error (ret);
+  if (!gnutls_ip_address_p (c_hostname))
+    {
+      ret = fn_gnutls_server_name_set (state, GNUTLS_NAME_DNS, c_hostname,
+                                      strlen (c_hostname));
+      if (ret < GNUTLS_E_SUCCESS)
+       return gnutls_make_error (ret);
+    }
 
   GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET;
   ret = emacs_gnutls_handshake (XPROCESS (proc));