Merge 786ffb3ae4 into merged_master (Bitcoin PR bitcoin/bitcoin#17160)

This commit is contained in:
Byron Hambly 2023-06-02 10:53:09 +00:00
commit 52bd78edf4

View file

@ -682,14 +682,11 @@ bool LookupSubNet(const std::string& strSubnet, CSubNet& ret, DNSLookupFn dns_lo
return false;
}
size_t slash = strSubnet.find_last_of('/');
std::vector<CNetAddr> vIP;
CNetAddr network;
std::string strAddress = strSubnet.substr(0, slash);
// TODO: Use LookupHost(const std::string&, CNetAddr&, bool) instead to just get
// one CNetAddr.
if (LookupHost(strAddress, vIP, 1, false, dns_lookup_function))
if (LookupHost(strAddress, network, false, dns_lookup_function))
{
CNetAddr network = vIP[0];
if (slash != strSubnet.npos)
{
std::string strNetmask = strSubnet.substr(slash + 1);
@ -701,14 +698,15 @@ bool LookupSubNet(const std::string& strSubnet, CSubNet& ret, DNSLookupFn dns_lo
}
else // If not a valid number, try full netmask syntax
{
CNetAddr netmask;
// Never allow lookup for netmask
if (LookupHost(strNetmask, vIP, 1, false, dns_lookup_function)) {
ret = CSubNet(network, vIP[0]);
if (LookupHost(strNetmask, netmask, false, dns_lookup_function)) {
ret = CSubNet(network, netmask);
return ret.IsValid();
}
}
}
else
else // Single IP subnet (<ipv4>/32 or <ipv6>/128)
{
ret = CSubNet(network);
return ret.IsValid();