Skip to content

Commit

Permalink
add pointer alignment check
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Jun 6, 2024
1 parent d0e431f commit f904e15
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sdk/program/src/sysvar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ fn get_sysvar(
let sysvar_id = sysvar_id as *const _ as *const u8;
let var_addr = dst as *mut _ as *mut u8;

// Check that the provided destination buffer is aligned to 8.
if var_addr.align_offset(8) != 0 {
return Err(ProgramError::InvalidArgument);
}

#[cfg(target_os = "solana")]
let result = unsafe { crate::syscalls::sol_get_sysvar(sysvar_id, var_addr, offset, length) };

Expand Down

0 comments on commit f904e15

Please sign in to comment.