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

flamenco: make transaction parsing errors return sanitize failure error #4055

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -2778,3 +2778,4 @@ dump/test-vectors/txn/fixtures/programs/2ab448fbadb0b964c56472758c7a46920f8591e5
dump/test-vectors/txn/fixtures/programs/e54e613fb6cab91a508bda54fff4d5ea2e238ee3_1777641.fix
dump/test-vectors/txn/fixtures/programs/b7d8956145950269da4dc2215fd6f149d1261e0b_1768662.fix
dump/test-vectors/txn/fixtures/programs/39376265439c3d3765a1a9b94d1beb3e643b6653_1769070.fix
dump/test-vectors/txn/fixtures/programs/a6d7f4390dadb86e7aa5414a054cc6e239eec615_1094896.fix
12 changes: 12 additions & 0 deletions src/flamenco/runtime/tests/fd_exec_instr_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ _txn_context_create_and_exec( fd_exec_instr_test_runner_t * runner,
/* Create the raw txn (https://solana.com/docs/core/transactions#transaction-size) */
cali-jumptrading marked this conversation as resolved.
Show resolved Hide resolved
uchar * txn_raw_begin = fd_scratch_alloc( alignof(uchar), 10000 ); // max txn size is 1232 but we allocate extra for safety
uchar * txn_raw_cur_ptr = txn_raw_begin;
int txn_parse_error = 0;

/* Compact array of signatures (https://solana.com/docs/core/transactions#transaction)
Note that although documentation interchangably refers to the signature cnt as a compact-u16
Expand Down Expand Up @@ -842,6 +843,11 @@ _txn_context_create_and_exec( fd_exec_instr_test_runner_t * runner,
// Compact array of 8-bit data
pb_bytes_array_t * data = test_ctx->tx.message.instructions[i].data;
if( data ) {
uint data_len_raw = data->size;
if( data_len_raw > USHORT_MAX ) {
txn_parse_error = -1;
}

ushort data_len = (ushort) data->size;
_add_compact_u16( &txn_raw_cur_ptr, data_len );
_add_to_data( &txn_raw_cur_ptr, data->bytes, data_len );
Expand Down Expand Up @@ -908,6 +914,12 @@ _txn_context_create_and_exec( fd_exec_instr_test_runner_t * runner,
/* Setup the spad for account allocation */
task_info->txn_ctx->spad = runner->spad;

/* Set the sanitize error if the txn was incorrectly formatted. */
if( txn_parse_error ) {
txn->flags = 0U;
task_info->exec_res = FD_RUNTIME_TXN_ERR_SANITIZE_FAILURE;
}

fd_runtime_pre_execute_check( task_info );

if( !task_info->exec_res ) {
Expand Down