LCOV - code coverage report
Current view: top level - ballet/pb - fuzz_pb_tokenize.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 7 7 100.0 %
Date: 2026-01-24 04:58:51 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include <assert.h>
       2             : #include <stdio.h>
       3             : #include <stdlib.h>
       4             : 
       5             : #include "../../util/fd_util.h"
       6             : #include "../../util/sanitize/fd_fuzz.h"
       7             : #include "fd_pb_tokenize.h"
       8             : 
       9             : int
      10             : LLVMFuzzerInitialize( int  *   argc,
      11          12 :                       char *** argv ) {
      12             :   /* Set up shell without signal handlers */
      13          12 :   putenv( "FD_LOG_BACKTRACE=0" );
      14          12 :   fd_boot( argc, argv );
      15          12 :   atexit( fd_halt );
      16          12 :   fd_log_level_core_set(3); /* crash on warning log */
      17          12 :   return 0;
      18          12 : }
      19             : 
      20             : int
      21             : LLVMFuzzerTestOneInput( uchar const * data,
      22             :                         ulong         size ) {
      23             :   fd_pb_inbuf_t buf[1];
      24             :   FD_TEST( fd_pb_inbuf_init( buf, data, size ) );
      25             :   while( fd_pb_inbuf_sz( buf ) ) {
      26             :     fd_pb_tlv_t tlv[1];
      27             :     if( !fd_pb_read_tlv( buf, tlv ) ) return 0;
      28             :     switch( tlv->wire_type ) {
      29             :     case FD_PB_WIRE_TYPE_VARINT:
      30             :     case FD_PB_WIRE_TYPE_I64:
      31             :     case FD_PB_WIRE_TYPE_I32:
      32             :       break;
      33             :     case FD_PB_WIRE_TYPE_LEN:
      34             :       if( fd_pb_inbuf_sz( buf )<tlv->len ) return 0;
      35             :       fd_pb_inbuf_skip( buf, tlv->len );
      36             :       break;
      37             :     default:
      38             :       FD_LOG_CRIT(( "invalid wire type" ));
      39             :     }
      40             :   }
      41             :   return 0;
      42             : }

Generated by: LCOV version 1.14