aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2020-08-21 16:10:48 +0200
committerJon Atack <jon@atack.com>2020-08-26 11:57:30 +0200
commitfb56d37612dea6666e7da73d671311a697570dae (patch)
treecf08424927bce9293cbb42f30b0758c271b43841 /src/net_processing.cpp
parentaa3621385ee66c9dde5c632c0a79fba3a6ea2d62 (diff)
downloadbitcoin-fb56d37612dea6666e7da73d671311a697570dae.tar.xz
p2p: ensure inv is GenMsgTx before ToGenTxid in inv processing
and otherwise log that an unknown INV type was received. In INV processing, when handling transaction type inv messages, ToGenTxid() expects that we constructed the CInv ourselves or that we verified that it is for a transaction type CInv. Therefore, change this `else` branch into an `else if (inv.GenMsgTx())` to make this safer and log any INVs that fall through.
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index b9f0e1f98e..0bd5e56ddd 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2672,7 +2672,7 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
// then fetch the blocks we need to catch up.
best_block = &inv.hash;
}
- } else {
+ } else if (inv.IsGenTxMsg()) {
const GenTxid gtxid = ToGenTxid(inv);
const bool fAlreadyHave = AlreadyHaveTx(gtxid, mempool);
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId());
@@ -2685,6 +2685,8 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
} else if (!fAlreadyHave && !m_chainman.ActiveChainstate().IsInitialBlockDownload()) {
RequestTx(State(pfrom.GetId()), gtxid, current_time);
}
+ } else {
+ LogPrint(BCLog::NET, "Unknown inv type \"%s\" received from peer=%d\n", inv.ToString(), pfrom.GetId());
}
}