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)
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
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34272.
<!--021abf342d371248e50ceaed478a90ca-->
See the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
utACK 2f5b1c5f80590ffa6b5a5bcfb21fddb1dc22e852
Trivial change to an 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)
FWIW I think I hit this on the fuzz tests here: https://github.com/willcl-ark/bitcoin/actions/runs/20883835381/job/60004100089#step:10:5614 So it may be possible for this to cause CI failure, at least.
@willcl-ark No, that is #33999 from the input fuzz_corpora/psbt/3fa30f92df4e391124a56b76cc3db3eb71b5d69c from commit https://github.com/bitcoin-core/qa-assets/pull/252/changes/00c335ca2ac2831fdf3d0fc2197ac509530ae13b
@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.
ACK 2f5b1c5f80590ffa6b5a5bcfb21fddb1dc22e852