Skip to content

Commit 2530bf2

Browse files
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 commit 37886d5 and merged as part of #11568 two days ago did not lock cs_main prior to accessing mapBlockIndex.
1 parent bb9ab0f commit 2530bf2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,8 @@ bool static ProcessHeadersMessage(CNode *pfrom, CConnman *connman, const std::ve
12621262
if (!ProcessNewBlockHeaders(headers, state, chainparams, &pindexLast, &first_invalid_header)) {
12631263
int nDoS;
12641264
if (state.IsInvalid(nDoS)) {
1265+
LOCK(cs_main);
12651266
if (nDoS > 0) {
1266-
LOCK(cs_main);
12671267
Misbehaving(pfrom->GetId(), nDoS);
12681268
}
12691269
if (punish_duplicate_invalid && mapBlockIndex.find(first_invalid_header.GetHash()) != mapBlockIndex.end()) {

0 commit comments

Comments
 (0)