mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
p2p: add assertion for BlockTransactionsRequest indexes
Adds Assume() check in net_processing after deserialization and validate DifferenceFormatter Class invariant.
This commit is contained in:
@@ -4135,6 +4135,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
if (msg_type == NetMsgType::GETBLOCKTXN) {
|
||||
BlockTransactionsRequest req;
|
||||
vRecv >> req;
|
||||
// Verify differential encoding invariant: indexes must be strictly increasing
|
||||
// DifferenceFormatter should guarantee this property during deserialization
|
||||
for (size_t i = 1; i < req.indexes.size(); ++i) {
|
||||
Assume(req.indexes[i] > req.indexes[i-1]);
|
||||
}
|
||||
|
||||
std::shared_ptr<const CBlock> recent_block;
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user