Check index out of bound also for tx inputs not only for psbt inputs

This commit is contained in:
Riccardo Casatta
2021-05-06 14:41:30 +02:00
parent 3c7bae9ce9
commit 7961ae7f8e
3 changed files with 49 additions and 3 deletions

View File

@@ -1497,7 +1497,7 @@ where
}
#[cfg(test)]
mod test {
pub(crate) mod test {
use std::str::FromStr;
use bitcoin::{util::psbt, Network};

View File

@@ -476,7 +476,7 @@ impl ComputeSighash for Legacy {
psbt: &psbt::PartiallySignedTransaction,
input_index: usize,
) -> Result<(SigHash, SigHashType), SignerError> {
if input_index >= psbt.inputs.len() {
if input_index >= psbt.inputs.len() || input_index >= psbt.global.unsigned_tx.input.len() {
return Err(SignerError::InputIndexOutOfRange);
}
@@ -524,7 +524,7 @@ impl ComputeSighash for Segwitv0 {
psbt: &psbt::PartiallySignedTransaction,
input_index: usize,
) -> Result<(SigHash, SigHashType), SignerError> {
if input_index >= psbt.inputs.len() {
if input_index >= psbt.inputs.len() || input_index >= psbt.global.unsigned_tx.input.len() {
return Err(SignerError::InputIndexOutOfRange);
}