Skip to content

Commit e2c2b7b

Browse files
authored
Small fixes
1 parent d375cf0 commit e2c2b7b

File tree

1 file changed

+12
-17
lines changed
  • not-so-smart-contracts/solana/sysvar_account_check

1 file changed

+12
-17
lines changed

not-so-smart-contracts/solana/sysvar_account_check/README.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,19 @@ Here, `load_current_index` and `load_instruction_at` are functions that don't ve
99

1010
### Example Contract
1111
```rust
12-
pub fn verify_signatures(
13-
account_info: &AccountInfo
14-
) -> ProgramResult {
15-
16-
let index = solana_program::sysvar::instructions::load_current_index(
12+
pub fn verify_signatures(account_info: &AccountInfo) -> ProgramResult {
13+
let index = solana_program::sysvar::instructions::load_current_index(
1714
&account_info.try_borrow_mut_data()?,
18-
);
19-
20-
let secp_instruction = sysvar::instructions::load_instruction_at(
21-
(index - 1) as usize,
22-
&account_info.try_borrow_mut_data()?,
23-
);
24-
25-
if secp_instruction.program_id != secp256k1_program::id() {
26-
return Err(InvalidSecpInstruction.into());
27-
}
28-
29-
...
15+
);
16+
17+
let secp_instruction = sysvar::instructions::load_instruction_at(
18+
(index - 1) as usize,
19+
&account_info.try_borrow_mut_data()?,
20+
);
21+
if secp_instruction.program_id != secp256k1_program::id() {
22+
return Err(InvalidSecpInstruction.into());
23+
}
24+
...
3025
}
3126
```
3227
Refer to [Mitigation](https://github.com/crytic/building-secure-contracts/tree/master/not-so-smart-contracts/solana/sysvar_account_check#Mitigation) to understand what's wrong with these functions and how sysvar account checks were added.

0 commit comments

Comments
 (0)