]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix peerSelectDnsResults() IP address cycling
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 2 Feb 2014 01:24:53 +0000 (18:24 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 2 Feb 2014 01:24:53 +0000 (18:24 -0700)
The local ip variable is the index of the IP address to be used.
Loop counter n is only used to prevent cycling indefinitely and should
not be used to access the array indexes.

src/peer_select.cc

index 5705a140fc54d34b095c6a358e0507ac974fa730..966a01f23a13713282559ffd08ceeff6113be501 100644 (file)
@@ -339,14 +339,14 @@ peerSelectDnsResults(const ipcache_addrs *ia, const DnsLookupDetails &details, v
 
             // for TPROXY spoofing we must skip unusable addresses.
             if (psstate->request->flags.spoofClientIp && !(fs->_peer && fs->_peer->options.no_tproxy) ) {
-                if (ia->in_addrs[n].isIPv4() != psstate->request->client_addr.isIPv4()) {
+                if (ia->in_addrs[ip].isIPv4() != psstate->request->client_addr.isIPv4()) {
                     // we CAN'T spoof the address on this link. find another.
                     continue;
                 }
             }
 
             p = new Comm::Connection();
-            p->remote = ia->in_addrs[n];
+            p->remote = ia->in_addrs[ip];
 
             // when IPv6 is disabled we cannot use it
             if (!Ip::EnableIpv6 && p->remote.isIPv6()) {