[Pkg-bitcoin-commits] [bitcoin] 99/126: net: Add missing lock in ProcessHeadersMessage(...)

Jonas Smedegaard dr at jones.dk
Mon Nov 13 20:02:58 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.15.1_dfsg-1
in repository bitcoin.

commit ec8dedff4683220cb30b69df7f987546536565ab
Author: practicalswift <practicalswift at users.noreply.github.com>
Date:   Mon Oct 30 14:28:19 2017 +0100

    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 37886d5e2f9992678dea4b1bd893f4f10d61d3ad and merged
    as part of #11568 two days ago did not lock cs_main prior to accessing
    mapBlockIndex.
    
    Github-Pull: #11578
    Rebased-From: 2530bf27b72e53cc6ffec27de35f3b487984833d
---
 src/net_processing.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index f677915..69db5d7 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -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()) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/bitcoin.git



More information about the Pkg-bitcoin-commits mailing list