LCOV - code coverage report
Current view: top level - ballet/txn - fuzz_txn_parse.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 8 8 100.0 %
Date: 2026-03-19 05:48:49 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #if !FD_HAS_HOSTED
       2             : #error "This target requires FD_HAS_HOSTED"
       3             : #endif
       4             : 
       5             : #include <stdio.h>
       6             : #include <stdlib.h>
       7             : 
       8             : #include "../../util/fd_util.h"
       9             : #include "../../util/sanitize/fd_fuzz.h"
      10             : #include "fd_txn.h"
      11             : 
      12             : int
      13             : LLVMFuzzerInitialize( int  *   argc,
      14          12 :                       char *** argv ) {
      15             :   /* Set up shell without signal handlers */
      16          12 :   putenv( "FD_LOG_BACKTRACE=0" );
      17          12 :   setenv( "FD_LOG_PATH", "", 0 );
      18          12 :   fd_boot( argc, argv );
      19          12 :   fd_log_level_core_set(3); /* crash on warning log */
      20          12 :   atexit( fd_halt );
      21          12 :   return 0;
      22          12 : }
      23             : 
      24             : int
      25             : LLVMFuzzerTestOneInput( uchar const * data,
      26             :                         ulong         size ) {
      27             :   if( FD_UNLIKELY( size>=1232UL ) ) return -1;
      28             : 
      29             :   uchar __attribute__((aligned((alignof(fd_txn_t))))) txn_buf[ FD_TXN_MAX_SZ ];
      30             :   fd_txn_parse_counters_t counters = {0};
      31             : 
      32             :   ulong sz = fd_txn_parse( data, size, txn_buf, &counters );
      33             : 
      34             :   FD_COMPILER_UNPREDICTABLE(sz);
      35             :   FD_COMPILER_MFENCE();
      36             : 
      37             :   if( FD_LIKELY( sz>0UL ) ) {
      38             :     FD_FUZZ_MUST_BE_COVERED;
      39             :     fd_txn_t * txn = (fd_txn_t *)txn_buf;
      40             :     FD_TEST( fd_txn_footprint( txn->instr_cnt, txn->addr_table_lookup_cnt )<=FD_TXN_MAX_SZ );
      41             :   }
      42             : 
      43             :   FD_FUZZ_MUST_BE_COVERED;
      44             :   return 0;
      45             : }

Generated by: LCOV version 1.14