]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3084: IPv6 without Host: header in request causes connection to hang
authorAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 22 Oct 2010 13:23:09 +0000 (07:23 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 22 Oct 2010 13:23:09 +0000 (07:23 -0600)
accel and intercept mode URL re-generation used NtoA instead of ToHostname.
This results in the URL incorrectly wrapping the raw-IPv6 and problems
connecting to non-existent addresses in some cases.

src/client_side.cc
src/ip/Address.h

index eb7f749c7cf318c3ebef5ac19fcf8d32b3992fc3..0724e448770dbbbc4e4e1ca4ea014e034d4d6d43 100644 (file)
@@ -1920,7 +1920,7 @@ prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, char *url,
     int vhost = conn->port->vhost;
     int vport = conn->port->vport;
     char *host;
-    char ntoabuf[MAX_IPSTRLEN];
+    char ipbuf[MAX_IPSTRLEN];
 
     http->flags.accel = 1;
 
@@ -1978,19 +1978,19 @@ prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, char *url,
         /* Put the local socket IP address as the hostname.  */
         int url_sz = strlen(url) + 32 + Config.appendDomainLen;
         http->uri = (char *)xcalloc(url_sz, 1);
+        http->getConn()->me.ToHostname(ipbuf,MAX_IPSTRLEN);
         snprintf(http->uri, url_sz, "%s://%s:%d%s",
                  http->getConn()->port->protocol,
-                 http->getConn()->me.NtoA(ntoabuf,MAX_IPSTRLEN),
-                 http->getConn()->me.GetPort(), url);
+                 ipbuf, http->getConn()->me.GetPort(), url);
         debugs(33, 5, "ACCEL VPORT REWRITE: '" << http->uri << "'");
     } else if (vport > 0) {
         /* Put the local socket IP address as the hostname, but static port  */
         int url_sz = strlen(url) + 32 + Config.appendDomainLen;
         http->uri = (char *)xcalloc(url_sz, 1);
+        http->getConn()->me.ToHostname(ipbuf,MAX_IPSTRLEN);
         snprintf(http->uri, url_sz, "%s://%s:%d%s",
                  http->getConn()->port->protocol,
-                 http->getConn()->me.NtoA(ntoabuf,MAX_IPSTRLEN),
-                 vport, url);
+                 ipbuf, vport, url);
         debugs(33, 5, "ACCEL VPORT REWRITE: '" << http->uri << "'");
     }
 }
@@ -1999,7 +1999,7 @@ static void
 prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, char *url, const char *req_hdr)
 {
     char *host;
-    char ntoabuf[MAX_IPSTRLEN];
+    char ipbuf[MAX_IPSTRLEN];
 
     if (*url != '/')
         return; /* already in good shape */
@@ -2017,10 +2017,10 @@ prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, char *url,
         /* Put the local socket IP address as the hostname.  */
         int url_sz = strlen(url) + 32 + Config.appendDomainLen;
         http->uri = (char *)xcalloc(url_sz, 1);
+        http->getConn()->me.ToHostname(ipbuf,MAX_IPSTRLEN),
         snprintf(http->uri, url_sz, "%s://%s:%d%s",
                  http->getConn()->port->protocol,
-                 http->getConn()->me.NtoA(ntoabuf,MAX_IPSTRLEN),
-                 http->getConn()->me.GetPort(), url);
+                 ipbuf, http->getConn()->me.GetPort(), url);
         debugs(33, 5, "TRANSPARENT REWRITE: '" << http->uri << "'");
     }
 }
index c42dfd4b5be6a602022b888b4ce2c1c53dcb9c8a..8fe0125afe02960aaa2a77f2c14758e70ef77679 100644 (file)
@@ -269,7 +269,7 @@ public:
      *  eg. 127.0.0.1 (IPv4) or [::1] (IPv6)
      \param buf Allocated buffer to write address to
      \param len byte length of buffer available for writing.
-     \return pointer to buffer received.
+     \return amount of buffer filled.
      */
     unsigned int ToHostname(char *buf, const unsigned int len) const;