Skip to content

Commit fa14df6

Browse files
MacroFakeUdjinM6
authored andcommitted
Merge bitcoin#25370: test: check for getblocktxn request with out-of-bounds tx index
5a8c321 test: check for `getblocktxn` request with out-of-bounds tx index (Sebastian Falbesoner) Pull request description: This PR adds missing test coverage for the `getblocktxn` message handler, in the case that any of the contained indices is out-of-bounds: https://github.com/bitcoin/bitcoin/blob/a05876619a3307daefec0946de8e3cbbe5b0157f/src/net_processing.cpp#L2180-L2183 ACKs for top commit: dunxen: ACK 5a8c321 Tree-SHA512: 2743c2c6d8aed57b22f825aefd60ba3e670321b60625a42ea7248e7b0fc41c73e9a5945153567c02824ba3b5f0fce7f4125bffc974973fc608b6ffbe49e14b65 Co-authored-by: UdjinM6 <[email protected]>
1 parent da4fd2e commit fa14df6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/functional/p2p_compactblocks.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,15 @@ def test_getblocktxn_handler(self, test_node):
561561
assert_equal(test_node.last_message["block"].block.sha256, int(block_hash, 16))
562562
assert "blocktxn" not in test_node.last_message
563563

564+
# Request with out-of-bounds tx index results in disconnect
565+
bad_peer = self.nodes[0].add_p2p_connection(TestP2PConn(cmpct_version=1))
566+
block_hash = node.getblockhash(chain_height)
567+
block = FromHex(CBlock(), node.getblock(block_hash, False))
568+
msg.block_txn_request = BlockTransactionsRequest(int(block_hash, 16), [len(block.vtx)])
569+
with node.assert_debug_log(['getblocktxn with out-of-bounds tx indices']):
570+
bad_peer.send_message(msg)
571+
bad_peer.wait_for_disconnect()
572+
564573
def test_compactblocks_not_at_tip(self, test_node):
565574
node = self.nodes[0]
566575
# Test that requesting old compactblocks doesn't work.

0 commit comments

Comments
 (0)