File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -184,7 +184,7 @@ void BanMan::SweepBanned()
184
184
while (it != m_banned.end ()) {
185
185
CSubNet sub_net = (*it).first ;
186
186
CBanEntry ban_entry = (*it).second ;
187
- if (now > ban_entry.nBanUntil ) {
187
+ if (!sub_net. IsValid () || now > ban_entry.nBanUntil ) {
188
188
m_banned.erase (it++);
189
189
m_is_dirty = true ;
190
190
notify_ui = true ;
Original file line number Diff line number Diff line change @@ -1109,6 +1109,17 @@ bool CSubNet::IsValid() const
1109
1109
return valid;
1110
1110
}
1111
1111
1112
+ bool CSubNet::SanityCheck () const
1113
+ {
1114
+ if (!(network.IsIPv4 () || network.IsIPv6 ())) return false ;
1115
+
1116
+ for (size_t x = 0 ; x < network.m_addr .size (); ++x) {
1117
+ if (network.m_addr [x] & ~netmask[x]) return false ;
1118
+ }
1119
+
1120
+ return true ;
1121
+ }
1122
+
1112
1123
bool operator ==(const CSubNet& a, const CSubNet& b)
1113
1124
{
1114
1125
return a.valid == b.valid && a.network == b.network && !memcmp (a.netmask , b.netmask , 16 );
Original file line number Diff line number Diff line change @@ -451,6 +451,8 @@ class CSubNet
451
451
// / Is this value valid? (only used to signal parse errors)
452
452
bool valid;
453
453
454
+ bool SanityCheck () const ;
455
+
454
456
public:
455
457
CSubNet ();
456
458
CSubNet (const CNetAddr& addr, uint8_t mask);
@@ -482,6 +484,8 @@ class CSubNet
482
484
READWRITE (obj.netmask );
483
485
}
484
486
READWRITE (obj.valid );
487
+ // Mark invalid if the result doesn't pass sanity checking.
488
+ SER_READ (obj, if (obj.valid ) obj.valid = obj.SanityCheck ());
485
489
}
486
490
};
487
491
You can’t perform that action at this time.
0 commit comments