Ignore incorrectly-serialized banlist.dat entries

This commit is contained in:
Pieter Wuille
2020-10-12 15:35:08 -07:00
parent 883cea7dea
commit 886be97af5
3 changed files with 16 additions and 1 deletions

View File

@@ -1109,6 +1109,17 @@ bool CSubNet::IsValid() const
return valid;
}
bool CSubNet::SanityCheck() const
{
if (!(network.IsIPv4() || network.IsIPv6())) return false;
for (size_t x = 0; x < network.m_addr.size(); ++x) {
if (network.m_addr[x] & ~netmask[x]) return false;
}
return true;
}
bool operator==(const CSubNet& a, const CSubNet& b)
{
return a.valid == b.valid && a.network == b.network && !memcmp(a.netmask, b.netmask, 16);