Skip to content

Commit 57425c1

Browse files
committed
gui: handle oversized config accounts
1 parent 3b2dd1f commit 57425c1

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

src/app/firedancer/topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ fd_topo_initialize( config_t * config ) {
433433
/**/ fd_topob_link( topo, "snapct_repr", "snapct_repr", 128UL, 0UL, 1UL )->permit_no_consumers = 1; /* TODO: wire in repair later */
434434
if( FD_LIKELY( config->tiles.gui.enabled ) ) {
435435
/**/ fd_topob_link( topo, "snapct_gui", "snapct_gui", 128UL, sizeof(fd_snapct_update_t), 1UL );
436-
/**/ fd_topob_link( topo, "snapin_gui", "snapin_gui", 4UL, FD_GUI_CONFIG_PARSE_CONFIG_KEYS_MAX_SZ+FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_MAX_SZ, 1UL );
436+
/**/ fd_topob_link( topo, "snapin_gui", "snapin_gui", 4UL, FD_GUI_CONFIG_PARSE_MAX_VALID_ACCT_SZ, 1UL );
437437
}
438438
if( vinyl_enabled ) {
439439
fd_topo_link_t * snapin_wh =

src/disco/gui/fd_gui_config_parse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_ICON_URI_SZ ( 80UL)
1313
#define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_KEYBASE_USERNAME_SZ (80UL)
1414
#define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_MAX_SZ ( 576UL) /* does not include size of ConfigKeys */
15+
#define FD_GUI_CONFIG_PARSE_MAX_VALID_ACCT_SZ (FD_GUI_CONFIG_PARSE_CONFIG_KEYS_MAX_SZ+FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_MAX_SZ)
1516

1617
/* The size of a ConfigKeys of length 2, which is the expected length of ValidatorInfo */
1718
#define FD_GUI_CONFIG_PARSE_CONFIG_KEYS_MAX_SZ (1UL + (32UL + 1UL)*2UL)

src/disco/gui/fd_gui_tile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ during_frag( fd_gui_ctx_t * ctx,
279279
}
280280

281281
if( FD_UNLIKELY( chunk<ctx->in[ in_idx ].chunk0 || chunk>ctx->in[ in_idx ].wmark || sz>ctx->in[ in_idx ].mtu ) )
282-
FD_LOG_ERR(( "chunk %lu %lu corrupt, not in range [%lu,%lu] or too large (%lu)", chunk, sz, ctx->in[ in_idx ].chunk0, ctx->in[ in_idx ].wmark, ctx->in[ in_idx ].mtu ));
282+
FD_LOG_ERR(( "in_kind %lu chunk %lu %lu corrupt, not in range [%lu,%lu] or too large (%lu)", ctx->in_kind[ in_idx ], chunk, sz, ctx->in[ in_idx ].chunk0, ctx->in[ in_idx ].wmark, ctx->in[ in_idx ].mtu ));
283283

284284
switch( ctx->in_kind[ in_idx ] ) {
285285
case IN_KIND_REPAIR_NET: {

src/discof/restore/fd_snapin_tile.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "../../disco/topo/fd_topo.h"
77
#include "../../disco/metrics/fd_metrics.h"
8+
#include "../../disco/gui/fd_gui_config_parse.h"
89
#include "../../flamenco/runtime/fd_txncache.h"
910
#include "../../flamenco/runtime/fd_system_ids.h"
1011
#include "../../flamenco/runtime/sysvar/fd_sysvar_slot_history.h"
@@ -517,7 +518,7 @@ handle_data_frag( fd_snapin_tile_t * ctx,
517518
early_exit = fd_snapin_process_account_data( ctx, result );
518519

519520
/* We exepect ConfigKeys Vec to be length 2 */
520-
if( FD_UNLIKELY( ctx->gui_out.idx!=ULONG_MAX && !memcmp( result->account_data.owner, fd_solana_config_program_id.key, sizeof(fd_hash_t) ) && result->account_data.data_sz && *(uchar *)result->account_data.data==2UL ) ) {
521+
if( FD_UNLIKELY( ctx->gui_out.idx!=ULONG_MAX && !memcmp( result->account_data.owner, fd_solana_config_program_id.key, sizeof(fd_hash_t) ) && result->account_data.data_sz && *(uchar *)result->account_data.data==2UL && result->account_data.data_sz<=FD_GUI_CONFIG_PARSE_MAX_VALID_ACCT_SZ ) ) {
521522
uchar * acct = fd_chunk_to_laddr( ctx->gui_out.mem, ctx->gui_out.chunk );
522523
fd_memcpy( acct, result->account_data.data, result->account_data.data_sz );
523524
fd_stem_publish( stem, ctx->gui_out.idx, 0UL, ctx->gui_out.chunk, result->account_data.data_sz, 0UL, 0UL, 0UL );

0 commit comments

Comments
 (0)