r15240 broke ipcacheCheckNumeric() because that function's static
storage was no longer reset properly between calls.
This bug is very different from bug 4741, but their symptoms (e.g.,
false "Host header forgery" SECURITY ALERTs) can be the same.
I did not realize that std::vector::resize(n, x) ignores x when the
vector size is already at least n. It is not a reset()-like method. My
tests did not have enough different IP-based URLs to expose this bug.
void
Dns::CachedIps::reset(const Ip::Address &ip)
{
- ips.resize(1, Dns::CachedIp(ip));
+ ips.clear();
+ ips.emplace_back(ip);
goodPosition = 0;
// Assume that the given IP is good because CachedIps are designed to never
// run out of good IPs.
if (cachedIp.ip == ip) {
if (auto position = positionOrNil)
*position = pos;
+ debugs(14, 7, ip << " at " << pos << " in " << *this);
return true;
}
}
// no such address; leave *position as is
+ debugs(14, 7, " no " << ip << " in " << *this);
return false;
}