Fail secp256k1 if the instruction data looks incorrect (#19300)

This commit is contained in:
Jack May
2021-08-19 13:13:54 -07:00
committed by GitHub
parent f59a55be17
commit 3ec33e7d02
9 changed files with 74 additions and 12 deletions

View File

@ -426,7 +426,11 @@ impl Transaction {
.collect()
}
pub fn verify_precompiles(&self, libsecp256k1_0_5_upgrade_enabled: bool) -> Result<()> {
pub fn verify_precompiles(
&self,
libsecp256k1_0_5_upgrade_enabled: bool,
libsecp256k1_fail_on_bad_count: bool,
) -> Result<()> {
for instruction in &self.message().instructions {
// The Transaction may not be sanitized at this point
if instruction.program_id_index as usize >= self.message().account_keys.len() {
@ -445,6 +449,7 @@ impl Transaction {
data,
&instruction_datas,
libsecp256k1_0_5_upgrade_enabled,
libsecp256k1_fail_on_bad_count,
);
e.map_err(|_| TransactionError::InvalidAccountIndex)?;
}

View File

@ -203,7 +203,11 @@ impl SanitizedTransaction {
}
/// Verify the encoded secp256k1 signatures in this transaction
pub fn verify_precompiles(&self, libsecp256k1_0_5_upgrade_enabled: bool) -> Result<()> {
pub fn verify_precompiles(
&self,
libsecp256k1_0_5_upgrade_enabled: bool,
libsecp256k1_fail_on_bad_count: bool,
) -> Result<()> {
for (program_id, instruction) in self.message.program_instructions_iter() {
if secp256k1_program::check_id(program_id) {
let instruction_datas: Vec<_> = self
@ -217,6 +221,7 @@ impl SanitizedTransaction {
data,
&instruction_datas,
libsecp256k1_0_5_upgrade_enabled,
libsecp256k1_fail_on_bad_count,
);
e.map_err(|_| TransactionError::InvalidAccountIndex)?;
}