From c41462e417026f79ee22903b6b7bebb8bac30c65 Mon Sep 17 00:00:00 2001 From: Richard Patel Date: Sat, 9 Jul 2022 01:23:27 +0200 Subject: [PATCH] Fix sol_get_processed_sibling_instruction on 32-bit hosts --- programs/bpf_loader/src/syscalls/mod.rs | 9 +++++---- sdk/program/src/instruction.rs | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/programs/bpf_loader/src/syscalls/mod.rs b/programs/bpf_loader/src/syscalls/mod.rs index 2c33dd96d1725c..e3bde1a2c0875e 100644 --- a/programs/bpf_loader/src/syscalls/mod.rs +++ b/programs/bpf_loader/src/syscalls/mod.rs @@ -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::( @@ -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; } diff --git a/sdk/program/src/instruction.rs b/sdk/program/src/instruction.rs index 7b2931847b463c..3a6ff0e0bbb7a1 100644 --- a/sdk/program/src/instruction.rs +++ b/sdk/program/src/instruction.rs @@ -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. @@ -698,8 +698,8 @@ pub fn get_processed_sibling_instruction(index: usize) -> Option { } { 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(