Skip to content

Commit e3a05e5

Browse files
Nicola-Osecnick0ve
andauthored
flamenco, vm: Fix inverted error code in CPI
Co-authored-by: Nicola Vella <[email protected]>
1 parent 80c7c14 commit e3a05e5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/flamenco/vm/syscall/fd_vm_syscall_cpi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,18 @@ static int
274274
fd_vm_syscall_cpi_check_instruction( fd_vm_t const * vm,
275275
ulong acct_cnt,
276276
ulong data_sz ) {
277-
/* https://github.com/solana-labs/solana/blob/eb35a5ac1e7b6abe81947e22417f34508f89f091/programs/bpf_loader/src/syscalls/cpi.rs#L958-L959 */
277+
/* https://github.com/anza-xyz/agave/blob/v3.1.2/program-runtime/src/cpi.rs#L146-L161 */
278278
if( FD_FEATURE_ACTIVE_BANK( vm->instr_ctx->bank, loosen_cpi_size_restriction ) ) {
279-
if( FD_UNLIKELY( data_sz > FD_CPI_MAX_INSTRUCTION_DATA_LEN ) ) {
280-
FD_LOG_WARNING(( "cpi: data too long (%#lx)", data_sz ));
281-
// SyscallError::MaxInstructionDataLenExceeded
282-
return FD_VM_SYSCALL_ERR_MAX_INSTRUCTION_DATA_LEN_EXCEEDED;
283-
}
284279
if( FD_UNLIKELY( acct_cnt > FD_CPI_MAX_INSTRUCTION_ACCOUNTS ) ) {
285280
FD_LOG_WARNING(( "cpi: too many accounts (%#lx)", acct_cnt ));
286281
// SyscallError::MaxInstructionAccountsExceeded
287282
return FD_VM_SYSCALL_ERR_MAX_INSTRUCTION_ACCOUNTS_EXCEEDED;
288283
}
284+
if( FD_UNLIKELY( data_sz > FD_CPI_MAX_INSTRUCTION_DATA_LEN ) ) {
285+
FD_LOG_WARNING(( "cpi: data too long (%#lx)", data_sz ));
286+
// SyscallError::MaxInstructionDataLenExceeded
287+
return FD_VM_SYSCALL_ERR_MAX_INSTRUCTION_DATA_LEN_EXCEEDED;
288+
}
289289
} else {
290290
// https://github.com/solana-labs/solana/blob/dbf06e258ae418097049e845035d7d5502fe1327/programs/bpf_loader/src/syscalls/cpi.rs#L1114
291291
ulong tot_sz = fd_ulong_sat_add( fd_ulong_sat_mul( FD_VM_RUST_ACCOUNT_META_SIZE, acct_cnt ), data_sz );

0 commit comments

Comments
 (0)