Skip to content

Commit 47b47ec

Browse files
committed
Tx validation: check count of auths
1 parent abfa486 commit 47b47ec

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/authorization.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,14 @@ pub fn get_address(verifying_key: &VerifyingKey) -> Address {
261261
pub fn verify_authorized_transaction(
262262
transaction: &AuthorizedTransaction,
263263
) -> Result<(), Error> {
264+
let verifications_required = &transaction.transaction.inputs.len();
265+
match transaction.authorizations.len().cmp(verifications_required) {
266+
std::cmp::Ordering::Less => return Err(Error::NotEnoughAuthorizations),
267+
std::cmp::Ordering::Equal => (),
268+
std::cmp::Ordering::Greater => {
269+
return Err(Error::TooManyAuthorizations);
270+
}
271+
}
264272
let tx_bytes_canonical = borsh::to_vec(&transaction.transaction)?;
265273
for auth in &transaction.authorizations {
266274
if !auth

0 commit comments

Comments
 (0)