Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F12944955
D8795.id26639.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D8795.id26639.diff
View Options
diff --git a/src/net.h b/src/net.h
--- a/src/net.h
+++ b/src/net.h
@@ -530,6 +530,10 @@
std::atomic<int> nBestHeight;
CClientUIInterface *clientInterface;
NetEventsInterface *m_msgproc;
+ /**
+ * Pointer to this node's banman. May be nullptr - check existence before
+ * dereferencing.
+ */
BanMan *m_banman;
/** SipHasher seeds for deterministic randomness */
diff --git a/src/net.cpp b/src/net.cpp
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1115,7 +1115,7 @@
SetSocketNoDelay(hSocket);
// Don't accept connections from banned peers.
- bool banned = m_banman->IsBanned(addr);
+ bool banned = m_banman && m_banman->IsBanned(addr);
if (!NetPermissions::HasFlag(permissionFlags,
NetPermissionFlags::PF_NOBAN) &&
banned) {
@@ -1127,7 +1127,7 @@
// Only accept connections from discouraged peers if our inbound slots
// aren't (almost) full.
- bool discouraged = m_banman->IsDiscouraged(addr);
+ bool discouraged = m_banman && m_banman->IsDiscouraged(addr);
if (!NetPermissions::HasFlag(permissionFlags,
NetPermissionFlags::PF_NOBAN) &&
nInbound + 1 >= nMaxInbound && discouraged) {
diff --git a/src/net_processing.h b/src/net_processing.h
--- a/src/net_processing.h
+++ b/src/net_processing.h
@@ -34,6 +34,10 @@
public NetEventsInterface {
private:
CConnman &m_connman;
+ /**
+ * Pointer to this node's banman. May be nullptr - check existence before
+ * dereferencing.
+ */
BanMan *const m_banman;
ChainstateManager &m_chainman;
CTxMemPool &m_mempool;
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2859,12 +2859,10 @@
addr.nTime = nNow - 5 * 24 * 60 * 60;
}
pfrom.AddAddressKnown(addr);
- // Do not process banned/discouraged addresses beyond remembering we
- // received them
- if (m_banman->IsDiscouraged(addr)) {
- continue;
- }
- if (m_banman->IsBanned(addr)) {
+ if (m_banman &&
+ (m_banman->IsDiscouraged(addr) || m_banman->IsBanned(addr))) {
+ // Do not process banned/discouraged addresses beyond
+ // remembering we received them
continue;
}
bool fReachable = IsReachable(addr);
@@ -4038,7 +4036,10 @@
std::vector<CAddress> vAddr = m_connman.GetAddresses();
FastRandomContext insecure_rand;
for (const CAddress &addr : vAddr) {
- if (!m_banman->IsDiscouraged(addr) && !m_banman->IsBanned(addr)) {
+ bool banned_or_discouraged =
+ m_banman &&
+ (m_banman->IsDiscouraged(addr) || m_banman->IsBanned(addr));
+ if (!banned_or_discouraged) {
pfrom.PushAddress(addr, insecure_rand);
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Feb 6, 16:29 (17 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5082699
Default Alt Text
D8795.id26639.diff (2 KB)
Attached To
D8795: [net/net processing] check banman pointer before dereferencing
Event Timeline
Log In to Comment