From: Amos Jeffries Date: Sat, 23 Oct 2010 13:54:37 +0000 (-0600) Subject: Author: Christophe Saout X-Git-Tag: SQUID_3_1_9~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68b86f94d7600b2db02414a846f93edba7c60131;p=thirdparty%2Fsquid.git Author: Christophe Saout Bug 3084: IPv6 without Host: header in request causes connection to hang 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. --- diff --git a/src/client_side.cc b/src/client_side.cc index 8a0f996581..8f28eb0879 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1796,7 +1796,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; @@ -1853,19 +1853,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 << "'"); } } @@ -1874,7 +1874,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 */ @@ -1892,10 +1892,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 << "'"); } } diff --git a/src/ip/IpAddress.h b/src/ip/IpAddress.h index 6768b5984e..0933c653fb 100644 --- a/src/ip/IpAddress.h +++ b/src/ip/IpAddress.h @@ -256,7 +256,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;