test_ed25519 fails if we randomly select index 1 (#22779)

(cherry picked from commit c1b543c74d)

# Conflicts:
#       sdk/src/ed25519_instruction.rs

Co-authored-by: Sean Young <sean@mess.org>
This commit is contained in:
mergify[bot]
2022-01-27 13:02:42 +00:00
committed by GitHub
parent fdc1b046bc
commit 92cc75b3ae
2 changed files with 9 additions and 1 deletions

View File

@ -44,7 +44,14 @@ pub mod test {
assert!(tx.verify_precompiles(&feature_set).is_ok());
let index = thread_rng().gen_range(0, instruction.data.len());
let index = loop {
let index = thread_rng().gen_range(0, instruction.data.len());
// byte 1 is not used, so this would not cause the verify to fail
if index != 1 {
break index;
}
};
instruction.data[index] = instruction.data[index].wrapping_add(12);
let tx = Transaction::new_signed_with_payer(
&[instruction],

View File

@ -108,6 +108,7 @@ pub fn verify_signatures(data: &[u8], instruction_datas: &[&[u8]]) -> Result<(),
let expected_data_size = num_signatures
.saturating_mul(SIGNATURE_OFFSETS_SERIALIZED_SIZE)
.saturating_add(SIGNATURE_OFFSETS_START);
// We do not check or use the byte at data[1]
if data.len() < expected_data_size {
return Err(Ed25519Error::InvalidInstructionDataSize);
}