diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-07-14 15:26:05 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-07-14 15:26:40 +0200 |
commit | 1a655e89cb4dbdf6c9b47626aff2f06fa4fa4dee (patch) | |
tree | 5c3a2b75bb283a132cbb8092ca01c929ab92800c /src/net_processing.cpp | |
parent | 07c83ce0399a2811bdd764b0cce347ba3bdbe37c (diff) | |
parent | ca3585a483ca5f6fc4cc54fd1530f89d13e5b7b0 (diff) |
Merge #19514: [net/net processing] check banman pointer before dereferencing
ca3585a483ca5f6fc4cc54fd1530f89d13e5b7b0 [net/net processing] check banman pointer before dereferencing (John Newbery)
Pull request description:
Although we currently don't do this, it should be possible to create a
CConnman or PeerLogicValidation without a Banman instance. Therefore
always check that banman exists before dereferencing the pointer.
Also add comments to the m_banman members of CConnman and
PeerLogicValidation to document that these may be nullptr.
ACKs for top commit:
jonatack:
ACK ca3585a
theStack:
ACK https://github.com/bitcoin/bitcoin/commit/ca3585a483ca5f6fc4cc54fd1530f89d13e5b7b0
Tree-SHA512: 726401c8921b9a502029ead34ae797473a1bc359d6e4e58dcbe3e25b70dde40bb100723be467fd3e2bf418892c493911998226de19c9d529d72034e3be26be48
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r-- | src/net_processing.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index ad349cf1a7..a776fdb214 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2491,8 +2491,10 @@ void ProcessMessage( if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60) addr.nTime = nNow - 5 * 24 * 60 * 60; pfrom.AddAddressKnown(addr); - if (banman->IsDiscouraged(addr)) continue; // Do not process banned/discouraged addresses beyond remembering we received them - if (banman->IsBanned(addr)) continue; + if (banman && (banman->IsDiscouraged(addr) || banman->IsBanned(addr))) { + // Do not process banned/discouraged addresses beyond remembering we received them + continue; + } bool fReachable = IsReachable(addr); if (addr.nTime > nSince && !pfrom.fGetAddr && vAddr.size() <= 10 && addr.IsRoutable()) { @@ -3346,7 +3348,8 @@ void ProcessMessage( std::vector<CAddress> vAddr = connman->GetAddresses(); FastRandomContext insecure_rand; for (const CAddress &addr : vAddr) { - if (!banman->IsDiscouraged(addr) && !banman->IsBanned(addr)) { + bool banned_or_discouraged = banman && (banman->IsDiscouraged(addr) || banman->IsBanned(addr)); + if (!banned_or_discouraged) { pfrom.PushAddress(addr, insecure_rand); } } |