diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-10-31 13:10:21 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-10-31 13:10:58 +0100 |
commit | 8335cb478183d800e274f6e96f9d7269ae584220 (patch) | |
tree | 1c58acb71c17cfafaed5f31f841ce46c915678bb /src | |
parent | bb9ab0fccfbadd5c032a2cd0bb3135049cffa42b (diff) | |
parent | 2530bf27b72e53cc6ffec27de35f3b487984833d (diff) | |
download | bitcoin-8335cb478183d800e274f6e96f9d7269ae584220.tar.xz |
Merge #11578: net: Add missing lock in ProcessHeadersMessage(...)
2530bf2 net: Add missing lock in ProcessHeadersMessage(...) (practicalswift)
Pull request description:
Add missing lock in `ProcessHeadersMessage(...)`.
Reading the variable `mapBlockIndex` requires holding the mutex `cs_main`.
The new "Disconnect outbound peers relaying invalid headers" code added in commit 37886d5e2f9992678dea4b1bd893f4f10d61d3ad and merged as part of #11568 two days ago did not lock `cs_main` prior to accessing `mapBlockIndex`.
Tree-SHA512: b799c234be8043d036183a00bc7867bbf3bd7ffe3baa94c88529da3b3cd0571c31ed11dadfaf29c5b8498341d6d0a3c928029a43b69f3267ef263682c91563a3
Diffstat (limited to 'src')
-rw-r--r-- | src/net_processing.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 4c3aacaf5f..92b7a75f73 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1262,8 +1262,8 @@ bool static ProcessHeadersMessage(CNode *pfrom, CConnman *connman, const std::ve if (!ProcessNewBlockHeaders(headers, state, chainparams, &pindexLast, &first_invalid_header)) { int nDoS; if (state.IsInvalid(nDoS)) { + LOCK(cs_main); if (nDoS > 0) { - LOCK(cs_main); Misbehaving(pfrom->GetId(), nDoS); } if (punish_duplicate_invalid && mapBlockIndex.find(first_invalid_header.GetHash()) != mapBlockIndex.end()) { |