mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
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.
This commit is contained in:
parent
aa3621385e
commit
fb56d37612
1 changed files with 3 additions and 1 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue