p2p: add assertion for BlockTransactionsRequest indexes

Adds Assume() check in net_processing after deserialization and validate DifferenceFormatter Class invariant.
This commit is contained in:
frankomosh
2025-08-28 16:53:58 +03:00
parent 58be359f6b
commit 65a10fc3c5

View File

@@ -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;
{