Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 123c4ec

Browse files
committed
add length check on record account length
1 parent cf7a030 commit 123c4ec

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

token/program-2022/src/proof.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ pub fn decode_proof_instruction_context<T: Pod + ZkProofData<U>, U: Pod>(
4545
let end_offset = start_offset
4646
.checked_add(std::mem::size_of::<T>())
4747
.ok_or(ProgramError::InvalidAccountData)?;
48-
let raw_proof_data = &record_account.data.borrow()[start_offset..end_offset];
48+
49+
let record_account_data = record_account.data.borrow();
50+
let raw_proof_data = record_account_data
51+
.get(start_offset..end_offset)
52+
.ok_or(ProgramError::AccountDataTooSmall)?;
4953

5054
bytemuck::try_from_bytes::<T>(raw_proof_data)
5155
.map(|proof_data| *ZkProofData::context_data(proof_data))

0 commit comments

Comments
 (0)