_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 */
*/
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;