Line data Source code
1 : #include "fd_util.h" 2 : 3 : #include <stdlib.h> 4 : #include <stdint.h> 5 : 6 : int 7 : LLVMFuzzerInitialize( int *argc, 8 12 : char ***argv ) { 9 12 : putenv( "FD_LOG_BACKTRACE=0" ); 10 12 : fd_boot( argc, argv ); 11 12 : (void) atexit( fd_halt ); 12 12 : fd_log_level_core_set( 1 ); 13 12 : return 0; 14 12 : } 15 : 16 : int 17 : LLVMFuzzerTestOneInput( uchar const *data, 18 : ulong size ) { 19 : ulong metadata_size = sizeof(ulong); 20 : if( size < metadata_size ) return 0; 21 : 22 : ulong seed = FD_LOAD( ulong, data ); 23 : size -= metadata_size; 24 : uchar * content = (uchar *)data + metadata_size; 25 : uchar * dst = malloc( size ); 26 : if( !dst ) return 0; 27 : 28 : ulong hash0 = fd_hash_memcpy( seed, dst, content, size ); 29 : ulong hash1 = fd_hash( seed, content, size ); 30 : if( FD_UNLIKELY( hash0!=hash1 ) ) FD_LOG_CRIT(( "hash mismatch" )); 31 : free( dst ); 32 : 33 : return 0; 34 : }