This PR fixes an off-by-one in a debug assertion in PSBTInputSignedAndVerified.
The function indexes psbt.inputs[input_index], so the assertion must not allow indexing at psbt.inputs.size().
Found during review: #31650 (review)
PSBTInputSignedAndVerified bounds assert
#34272
This PR fixes an off-by-one in a debug assertion in PSBTInputSignedAndVerified.
The function indexes psbt.inputs[input_index], so the assertion must not allow indexing at psbt.inputs.size().
Found during review: #31650 (review)
The previous `assert` used `>=`, allowing `input_index == psbt.inputs.size()` and out-of-bounds access in `psbt.inputs[input_index]`.
Found during review: https://github.com/bitcoin/bitcoin/pull/31650#discussion_r2685892867
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34272.
See the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.
assert, can be reliably assessed by local code inspection (2 lines).
Code reviewed; build & unit tests verified locally.
lgtm ACK 2f5b1c5f80590ffa6b5a5bcfb21fddb1dc22e852
This is just a refactor/doc change, because the UB can not be reached in the current code-base, and is assumed to be unreachable anyway (due to the use of assert)
@willcl-ark No, that is #33999 from the input fuzz_corpora/psbt/3fa30f92df4e391124a56b76cc3db3eb71b5d69c from commit bitcoin-core/qa-assets@00c335c
ah ok i see, thanks.