mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
Ignore incorrectly-serialized banlist.dat entries
This commit is contained in:
parent
883cea7dea
commit
886be97af5
3 changed files with 16 additions and 1 deletions
|
@ -184,7 +184,7 @@ void BanMan::SweepBanned()
|
||||||
while (it != m_banned.end()) {
|
while (it != m_banned.end()) {
|
||||||
CSubNet sub_net = (*it).first;
|
CSubNet sub_net = (*it).first;
|
||||||
CBanEntry ban_entry = (*it).second;
|
CBanEntry ban_entry = (*it).second;
|
||||||
if (now > ban_entry.nBanUntil) {
|
if (!sub_net.IsValid() || now > ban_entry.nBanUntil) {
|
||||||
m_banned.erase(it++);
|
m_banned.erase(it++);
|
||||||
m_is_dirty = true;
|
m_is_dirty = true;
|
||||||
notify_ui = true;
|
notify_ui = true;
|
||||||
|
|
|
@ -1109,6 +1109,17 @@ bool CSubNet::IsValid() const
|
||||||
return valid;
|
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)
|
bool operator==(const CSubNet& a, const CSubNet& b)
|
||||||
{
|
{
|
||||||
return a.valid == b.valid && a.network == b.network && !memcmp(a.netmask, b.netmask, 16);
|
return a.valid == b.valid && a.network == b.network && !memcmp(a.netmask, b.netmask, 16);
|
||||||
|
|
|
@ -451,6 +451,8 @@ class CSubNet
|
||||||
/// Is this value valid? (only used to signal parse errors)
|
/// Is this value valid? (only used to signal parse errors)
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
||||||
|
bool SanityCheck() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSubNet();
|
CSubNet();
|
||||||
CSubNet(const CNetAddr& addr, uint8_t mask);
|
CSubNet(const CNetAddr& addr, uint8_t mask);
|
||||||
|
@ -482,6 +484,8 @@ class CSubNet
|
||||||
READWRITE(obj.netmask);
|
READWRITE(obj.netmask);
|
||||||
}
|
}
|
||||||
READWRITE(obj.valid);
|
READWRITE(obj.valid);
|
||||||
|
// Mark invalid if the result doesn't pass sanity checking.
|
||||||
|
SER_READ(obj, if (obj.valid) obj.valid = obj.SanityCheck());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue