]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Strip trailing dot from hostname that is used when setting up SSL (STR #4011)
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 1 Feb 2012 04:18:13 +0000 (04:18 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 1 Feb 2012 04:18:13 +0000 (04:18 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10213 7a7537e8-13f0-0310-91df-b6672ffda945

cups/http.c

index be3b1ac242af36d14ee24cdb1c803040dc8a13b6..1e413c0d462b6c616e55c4a2351bbc8a4e30f398 100644 (file)
@@ -3869,7 +3869,8 @@ http_setup_ssl(http_t *http)              /* I - Connection to server */
   _cups_globals_t      *cg = _cupsGlobals();
                                        /* Pointer to library globals */
   int                  any_root;       /* Allow any root */
-  char                 *hostname;      /* Hostname */
+  char                 hostname[256],  /* Hostname */
+                       *hostptr;       /* Pointer into hostname */
 
 #  ifdef HAVE_LIBSSL
   SSL_CTX              *context;       /* Context for encryption */
@@ -3905,11 +3906,24 @@ http_setup_ssl(http_t *http)            /* I - Connection to server */
   */
 
   if (httpAddrLocalhost(http->hostaddr))
+  {
     any_root = 1;
+    strlcpy(hostname, "localhost", sizeof(hostname));
+  }
   else
+  {
+   /*
+    * Otherwise use the system-wide setting and make sure the hostname we have
+    * does not end in a trailing dot.
+    */
+
     any_root = cg->any_root;
 
-  hostname = httpAddrLocalhost(http->hostaddr) ? "localhost" : http->hostname;
+    strlcpy(hostname, http->hostname, sizeof(hostname));
+    if ((hostptr = hostname + strlen(hostname) - 1) >= hostname &&
+        *hostptr == '.')
+      *hostptr = '\0';
+  }
 
 #  ifdef HAVE_LIBSSL
   (void)any_root;