aboutsummaryrefslogtreecommitdiff
path: root/src/netaddress.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2020-10-12 15:35:08 -0700
committerPieter Wuille <pieter@wuille.net>2020-10-12 15:35:08 -0700
commit886be97af5d4aba338b23a7b20b8560be8156231 (patch)
treeccc1c69bdee6c79b398c1e031e81d48a2b54a89a /src/netaddress.cpp
parent883cea7dea3cedc9b45b6191f7d4e7be2d9a11ca (diff)
Ignore incorrectly-serialized banlist.dat entries
Diffstat (limited to 'src/netaddress.cpp')
-rw-r--r--src/netaddress.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/netaddress.cpp b/src/netaddress.cpp
index 147c775e61..4e100ff9ca 100644
--- a/src/netaddress.cpp
+++ b/src/netaddress.cpp
@@ -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);