From: Amos Jeffries Date: Sun, 2 Feb 2014 02:47:38 +0000 (-0700) Subject: Fix peerSelectDnsResults() IP address cycling X-Git-Tag: SQUID_3_4_3~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e7b1f953a4e5b338f44bc43cda637aed99a54be;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 7746de51e3..0eb1687520 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -337,14 +337,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()) {