Line data Source code
1 : #include "fd_snapshot_parser.h" 2 : #include <assert.h> 3 : #include <stdlib.h> 4 : 5 : #define ACCV_LG_SLOT_CNT 8 /* 256 hashmap slots */ 6 : 7 : static void * parser_mem; 8 : 9 : int 10 : LLVMFuzzerInitialize( int * argc, 11 : char *** argv ) { 12 : /* Set up shell without signal handlers */ 13 : putenv( "FD_LOG_BACKTRACE=0" ); 14 : fd_boot( argc, argv ); 15 : atexit( fd_halt ); 16 : fd_log_level_core_set ( 4 ); 17 : fd_log_level_logfile_set( 4 ); 18 : 19 : parser_mem = aligned_alloc( fd_snapshot_parser_align(), fd_snapshot_parser_footprint( 1024UL ) ); 20 : assert( parser_mem ); 21 : 22 : return 0; 23 : } 24 : 25 : static void 26 0 : manifest_cb( void * _ctx ) { 27 0 : (void)_ctx; 28 0 : } 29 : 30 : static void 31 : acc_hdr_cb( void * _ctx, 32 0 : fd_solana_account_hdr_t const * hdr ) { 33 0 : (void)_ctx; (void)hdr; 34 0 : } 35 : 36 : static void 37 : acc_data_cb( void * _ctx, 38 : uchar const * buf, 39 0 : ulong data_sz ) { 40 0 : (void)_ctx; (void)buf; (void)data_sz; 41 0 : } 42 : 43 : int 44 : LLVMFuzzerTestOneInput( uchar const * const data, 45 : ulong const size ) { 46 : fd_snapshot_parser_t * parser = fd_snapshot_parser_new( parser_mem, NULL, 42UL, 1024UL, manifest_cb, acc_hdr_cb, acc_data_cb ); 47 : assert( parser ); 48 : /* FIXME split input in the future */ 49 : uchar const * p = data; 50 : uchar const * end = data+size; 51 : while( p<end ) { 52 : p = fd_snapshot_parser_process_chunk( parser, data, size ); 53 : } 54 : assert( p==end ); 55 : return 0; 56 : }