Skip to content

Commit

Permalink
Merge #11578: net: Add missing lock in ProcessHeadersMessage(...)
Browse files Browse the repository at this point in the history
Summary:
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 37886d5 and merged as part of #11568 two days ago did not lock `cs_main` prior to accessing `mapBlockIndex`.

Tree-SHA512: b799c234be8043d036183a00bc7867bbf3bd7ffe3baa94c88529da3b3cd0571c31ed11dadfaf29c5b8498341d6d0a3c928029a43b69f3267ef263682c91563a3

Backport of Core PR11578
https://github.com/bitcoin/bitcoin/pull/11578/files

Test Plan:
ninja check
make check
test_runner.py
bitcoind # sanity check

Reviewers: deadalnix, Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D2890
  • Loading branch information
laanwj authored and jasonbcox committed May 9, 2019
1 parent 3d89108 commit 4f4f0f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Expand Up @@ -1590,8 +1590,8 @@ static bool ProcessHeadersMessage(const Config &config, CNode *pfrom,
&first_invalid_header)) {
int nDoS;
if (state.IsInvalid(nDoS)) {
LOCK(cs_main);
if (nDoS > 0) {
LOCK(cs_main);
Misbehaving(pfrom, nDoS, state.GetRejectReason());
}
if (punish_duplicate_invalid &&
Expand Down

0 comments on commit 4f4f0f7

Please sign in to comment.