Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sol_get_processed_sibling_instruction on 32-bit hosts #26522

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1750,8 +1750,9 @@ declare_syscall!(
result
);

if *data_len == instruction_context.get_instruction_data().len()
&& *accounts_len == instruction_context.get_number_of_instruction_accounts()
if *data_len == (instruction_context.get_instruction_data().len() as u64)
&& *accounts_len
== (instruction_context.get_number_of_instruction_accounts() as u64)
{
let program_id = question_mark!(
translate_type_mut::<Pubkey>(
Expand Down Expand Up @@ -1809,8 +1810,8 @@ declare_syscall!(
);
accounts.clone_from_slice(account_metas.as_slice());
}
*data_len = instruction_context.get_instruction_data().len();
*accounts_len = instruction_context.get_number_of_instruction_accounts();
*data_len = instruction_context.get_instruction_data().len() as u64;
*accounts_len = instruction_context.get_number_of_instruction_accounts() as u64;
*result = Ok(true as u64);
return;
}
Expand Down
8 changes: 4 additions & 4 deletions sdk/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,9 @@ impl CompiledInstruction {
#[derive(Default, Debug, Clone, Copy)]
pub struct ProcessedSiblingInstruction {
/// Length of the instruction data
pub data_len: usize,
pub data_len: u64,
/// Number of AccountMeta structures
pub accounts_len: usize,
pub accounts_len: u64,
}

/// Returns a sibling instruction from the processed sibling instruction list.
Expand Down Expand Up @@ -698,8 +698,8 @@ pub fn get_processed_sibling_instruction(index: usize) -> Option<Instruction> {
} {
let mut data = Vec::new();
let mut accounts = Vec::new();
data.resize_with(meta.data_len, u8::default);
accounts.resize_with(meta.accounts_len, AccountMeta::default);
data.resize_with(meta.data_len as usize, u8::default);
accounts.resize_with(meta.accounts_len as usize, AccountMeta::default);

let _ = unsafe {
crate::syscalls::sol_get_processed_sibling_instruction(
Expand Down