mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-22 08:09:19 +01:00
net: 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 commit37886d5e2fand merged as part of #11568 two days ago did not lock cs_main prior to accessing mapBlockIndex. Github-Pull: #11578 Rebased-From:2530bf27b7
This commit is contained in:
committed by
MarcoFalke
parent
59b210d9a7
commit
ec8dedff46
@@ -1250,8 +1250,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()) {
|
||||
|
||||
Reference in New Issue
Block a user