Line data Source code
1 : #if !FD_HAS_HOSTED 2 : #error "This target requires FD_HAS_HOSTED" 3 : #endif 4 : 5 : #include <assert.h> 6 : #include <stdlib.h> 7 : 8 : #include "fd_gui_config_parse.h" 9 : 10 : #include "../../ballet/utf8/fd_utf8.h" 11 : #include "../../util/fd_util.h" 12 : 13 : int 14 : LLVMFuzzerInitialize( int * argc, 15 12 : char *** argv ) { 16 : /* Set up shell without signal handlers */ 17 12 : putenv( "FD_LOG_BACKTRACE=0" ); 18 12 : putenv( "FD_LOG_PATH=" ); 19 12 : fd_boot( argc, argv ); 20 12 : fd_log_level_core_set(0); /* crash on debug log */ 21 12 : return 0; 22 12 : } 23 : 24 : int 25 : LLVMFuzzerTestOneInput( uchar const * data, 26 : ulong size ) { 27 : cJSON * json; 28 : fd_gui_config_parse_info_t validator_info[1]; 29 : fd_pubkey_t pubkey; 30 : int valid = fd_gui_config_parse_validator_info_check( data, size, &json, &pubkey ); 31 : 32 : if( valid ) { 33 : fd_gui_config_parse_validator_info( json, validator_info ); 34 : 35 : assert( fd_utf8_verify( validator_info->name, strlen( validator_info->name ) ) ); 36 : assert( fd_utf8_verify( validator_info->website, strlen( validator_info->website ) ) ); 37 : assert( fd_utf8_verify( validator_info->details, strlen( validator_info->details ) ) ); 38 : assert( fd_utf8_verify( validator_info->icon_uri, strlen( validator_info->icon_uri ) ) ); 39 : assert( fd_utf8_verify( validator_info->keybase_username, strlen( validator_info->keybase_username ) ) ); 40 : } 41 : return 0; 42 : }