p2p: add assertion for BlockTransactionsRequest indexes
Adds Assume() check in net_processing after deserialization and validate DifferenceFormatter Class invariant.
This commit is contained in:
1 parent
58be359f6b
commit
65a10fc3c5
1 file changed
+5
@@ -4135,6 +4135,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
|||||||
if (msg_type == NetMsgType::GETBLOCKTXN) {
|
if (msg_type == NetMsgType::GETBLOCKTXN) {
|
||||||
BlockTransactionsRequest req;
|
BlockTransactionsRequest req;
|
||||||
vRecv >> 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;
|
std::shared_ptr<const CBlock> recent_block;
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user