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

runtime: fix fd_account_can_data_be_resized substraction signedness #3834

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions src/flamenco/runtime/fd_account.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
/* FD_ACC_SZ_MAX is the hardcoded size limit of a Solana account. */

#define MAX_PERMITTED_DATA_LENGTH (10UL<<20) /* 10MiB */
#define MAX_PERMITTED_ACCOUNT_DATA_ALLOCS_PER_TXN (10UL<<21) /* 20MiB */
#define MAX_PERMITTED_ACCOUNT_DATA_ALLOCS_PER_TXN (10L<<21 ) /* 20MiB */

/* Convenience macro for `fd_account_check_num_insn_accounts()` */
#define CHECK_NUM_INSN_ACCS( _ctx, _expected ) do { \
Expand Down Expand Up @@ -374,8 +374,8 @@ fd_account_can_data_be_resized( fd_exec_instr_ctx_t const * instr_ctx,

/* The resize can not exceed the per-transaction maximum
https://github.com/firedancer-io/agave/blob/1e460f466da60a63c7308e267c053eec41dc1b1c/sdk/src/transaction_context.rs#L1107-L1111 */
ulong length_delta = fd_ulong_sat_sub( new_length, acct->dlen );
ulong new_accounts_resize_delta = fd_ulong_sat_add( instr_ctx->txn_ctx->accounts_resize_delta, length_delta );
long length_delta = fd_long_sat_sub( (long)new_length, (long)acct->dlen );
long new_accounts_resize_delta = fd_long_sat_add( (long)instr_ctx->txn_ctx->accounts_resize_delta, length_delta );
if( FD_UNLIKELY( new_accounts_resize_delta>MAX_PERMITTED_ACCOUNT_DATA_ALLOCS_PER_TXN ) ) {
*err = FD_EXECUTOR_INSTR_ERR_MAX_ACCS_DATA_ALLOCS_EXCEEDED;
return 0;
Expand Down
Loading