Skip to content

Commit

Permalink
fix region checks (#11651)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay authored Aug 17, 2020
1 parent 23fa84b commit 768b386
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions programs/bpf_loader/src/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ pub fn syscall_create_program_address(
)
})
.collect::<Result<Vec<_>, EbpfError<BPFError>>>()?;
let program_id = translate_type!(Pubkey, program_id_addr, rw_regions)?;
let program_id = translate_type!(Pubkey, program_id_addr, ro_regions)?;
let new_address =
Pubkey::create_program_address(&seeds, program_id).map_err(SyscallError::BadSeeds)?;
let address = translate_slice_mut!(u8, address_addr, 32, ro_regions)?;
let address = translate_slice_mut!(u8, address_addr, 32, rw_regions)?;
address.copy_from_slice(new_address.as_ref());
Ok(0)
}
Expand Down
7 changes: 2 additions & 5 deletions sdk/src/pubkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,13 @@ impl Pubkey {
address_bytes_addr: *const u8,
) -> u64;
};
let bytes = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
];
let mut bytes = [0; 32];
let result = unsafe {
sol_create_program_address(
seeds as *const _ as *const u8,
seeds.len() as u64,
program_id as *const _ as *const u8,
&bytes as *const _ as *const u8,
&mut bytes as *mut _ as *mut u8,
)
};
match result {
Expand Down

0 comments on commit 768b386

Please sign in to comment.