From: Amos Jeffries Date: Sun, 27 Jun 2010 09:54:35 +0000 (+1200) Subject: Author: Matthias Pitzl X-Git-Tag: SQUID_3_1_5~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bc9caf5ca6258bb830088cd4906781d7a562a3a8;p=thirdparty%2Fsquid.git Author: Matthias Pitzl Bug 2967: raw-IPv6 address URL with append_domain broken --- diff --git a/src/internal.cc b/src/internal.cc index b152feccfb..f6082d27e1 100644 --- a/src/internal.cc +++ b/src/internal.cc @@ -114,7 +114,12 @@ internalRemoteUri(const char *host, u_short port, const char *dir, const char *n * domains */ +#if USE_IPV6 + /* For IPV6 addresses also check for a colon */ + if (Config.appendDomain && !strchr(lc_host, '.') && !strchr(lc_host, ':')) +#else if (Config.appendDomain && !strchr(lc_host, '.')) +#endif strncat(lc_host, Config.appendDomain, SQUIDHOSTNAMELEN - strlen(lc_host) - 1); @@ -154,7 +159,12 @@ internalHostname(void) LOCAL_ARRAY(char, host, SQUIDHOSTNAMELEN + 1); xstrncpy(host, getMyHostname(), SQUIDHOSTNAMELEN); +#if USE_IPV6 + /* For IPV6 addresses also check for a colon */ + if (Config.appendDomain && !strchr(host, '.') && !strchr(host, ':')) +#else if (Config.appendDomain && !strchr(host, '.')) +#endif strncat(host, Config.appendDomain, SQUIDHOSTNAMELEN - strlen(host) - 1); diff --git a/src/tools.cc b/src/tools.cc index 70f961c459..f56313e7a2 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1110,7 +1110,12 @@ parseEtcHosts(void) *nt = '\0'; debugs(1, 5, "etc_hosts: got hostname '" << lt << "'"); +#if USE_IPV6 + /* For IPV6 addresses also check for a colon */ + if (Config.appendDomain && !strchr(lt, '.') && !strchr(lt, ':')) { +#else if (Config.appendDomain && !strchr(lt, '.')) { +#endif /* I know it's ugly, but it's only at reconfig */ strncpy(buf2, lt, 512); strncat(buf2, Config.appendDomain, 512 - strlen(lt) - 1); diff --git a/src/url.cc b/src/url.cc index d9ac26f6d7..070f5eef2d 100644 --- a/src/url.cc +++ b/src/url.cc @@ -351,7 +351,12 @@ urlParse(const HttpRequestMethod& method, char *url, HttpRequest *request) return NULL; } +#if USE_IPV6 + /* For IPV6 addresses also check for a colon */ + if (Config.appendDomain && !strchr(host, '.') && !strchr(host, ':')) +#else if (Config.appendDomain && !strchr(host, '.')) +#endif strncat(host, Config.appendDomain, SQUIDHOSTNAMELEN - strlen(host) - 1); /* remove trailing dots from hostnames */