From: Amos Jeffries Date: Sun, 2 Feb 2014 01:24:53 +0000 (-0700) Subject: Fix peerSelectDnsResults() IP address cycling X-Git-Tag: SQUID_3_5_0_1~390 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b43f99318deaf9224506262fe7c2d59dc558319c;p=thirdparty%2Fsquid.git Fix peerSelectDnsResults() IP address cycling 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. --- diff --git a/src/peer_select.cc b/src/peer_select.cc index 5705a140fc..966a01f23a 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -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()) {