MOS Source Code
Loading...
Searching...
No Matches
fuzztest.c File Reference
#include <pb_decode.h>
#include <pb_encode.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <malloc_wrappers.h>
#include "random_data.h"
#include "validation.h"
#include "flakystream.h"
#include "test_helpers.h"
#include "alltypes_static.pb.h"
#include "alltypes_pointer.pb.h"
#include "alltypes_callback.pb.h"
#include "alltypes_proto3_static.pb.h"
#include "alltypes_proto3_pointer.pb.h"
+ Include dependency graph for fuzztest.c:

Go to the source code of this file.

Macros

#define FUZZTEST_BUFSIZE   256*1024
 
#define FUZZTEST_MAX_STANDALONE_BUFSIZE   16384
 
#define FUZZTEST_PROTO2_STATIC
 
#define FUZZTEST_PROTO3_STATIC
 
#define FUZZTEST_PROTO2_POINTER
 
#define FUZZTEST_PROTO3_POINTER
 
#define FUZZTEST_IO_ERRORS
 

Functions

static uint32_t xor32_checksum (const void *data, size_t len)
 
static bool do_decode (const uint8_t *buffer, size_t msglen, size_t structsize, const pb_msgdesc_t *msgtype, unsigned flags, bool assert_success)
 
static bool do_stream_decode (const uint8_t *buffer, size_t msglen, size_t fail_after, size_t structsize, const pb_msgdesc_t *msgtype, bool assert_success)
 
static bool field_callback (pb_istream_t *stream, const pb_field_t *field, void **arg)
 
static bool submsg_callback (pb_istream_t *stream, const pb_field_t *field, void **arg)
 
bool do_callback_decode (const uint8_t *buffer, size_t msglen, bool assert_success)
 
void do_roundtrip (const uint8_t *buffer, size_t msglen, size_t structsize, const pb_msgdesc_t *msgtype)
 
void do_roundtrips (const uint8_t *data, size_t size, bool expect_valid)
 
int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)
 
static bool generate_base_message (uint8_t *buffer, size_t *msglen)
 
static void run_iteration ()
 
int main (int argc, char **argv)
 

Variables

static size_t g_bufsize = 256*1024
 
static int g_sentinel
 

Macro Definition Documentation

◆ FUZZTEST_BUFSIZE

#define FUZZTEST_BUFSIZE   256*1024

Definition at line 29 of file fuzztest.c.

◆ FUZZTEST_MAX_STANDALONE_BUFSIZE

#define FUZZTEST_MAX_STANDALONE_BUFSIZE   16384

Definition at line 32 of file fuzztest.c.

Referenced by main().

◆ FUZZTEST_PROTO2_STATIC

#define FUZZTEST_PROTO2_STATIC

Definition at line 44 of file fuzztest.c.

◆ FUZZTEST_PROTO3_STATIC

#define FUZZTEST_PROTO3_STATIC

Definition at line 45 of file fuzztest.c.

◆ FUZZTEST_PROTO2_POINTER

#define FUZZTEST_PROTO2_POINTER

Definition at line 46 of file fuzztest.c.

◆ FUZZTEST_PROTO3_POINTER

#define FUZZTEST_PROTO3_POINTER

Definition at line 47 of file fuzztest.c.

◆ FUZZTEST_IO_ERRORS

#define FUZZTEST_IO_ERRORS

Definition at line 48 of file fuzztest.c.

Function Documentation

◆ xor32_checksum()

static uint32_t xor32_checksum ( const void * data,
size_t len )
static

Definition at line 51 of file fuzztest.c.

Referenced by do_roundtrip().

◆ do_decode()

static bool do_decode ( const uint8_t * buffer,
size_t msglen,
size_t structsize,
const pb_msgdesc_t * msgtype,
unsigned flags,
bool assert_success )
static

Definition at line 65 of file fuzztest.c.

+ Here is the call graph for this function:

◆ do_stream_decode()

static bool do_stream_decode ( const uint8_t * buffer,
size_t msglen,
size_t fail_after,
size_t structsize,
const pb_msgdesc_t * msgtype,
bool assert_success )
static

Definition at line 112 of file fuzztest.c.

Referenced by do_roundtrips().

+ Here is the call graph for this function:

◆ field_callback()

static bool field_callback ( pb_istream_t * stream,
const pb_field_t * field,
void ** arg )
static

Definition at line 144 of file fuzztest.c.

Referenced by do_callback_decode().

+ Here is the call graph for this function:

◆ submsg_callback()

static bool submsg_callback ( pb_istream_t * stream,
const pb_field_t * field,
void ** arg )
static

Definition at line 152 of file fuzztest.c.

Referenced by do_callback_decode().

◆ do_callback_decode()

bool do_callback_decode ( const uint8_t * buffer,
size_t msglen,
bool assert_success )

Definition at line 160 of file fuzztest.c.

Referenced by do_roundtrips().

+ Here is the call graph for this function:

◆ do_roundtrip()

void do_roundtrip ( const uint8_t * buffer,
size_t msglen,
size_t structsize,
const pb_msgdesc_t * msgtype )

Definition at line 198 of file fuzztest.c.

Referenced by do_roundtrips().

+ Here is the call graph for this function:

◆ do_roundtrips()

void do_roundtrips ( const uint8_t * data,
size_t size,
bool expect_valid )

Definition at line 289 of file fuzztest.c.

Referenced by LLVMFuzzerTestOneInput(), and run_iteration().

+ Here is the call graph for this function:

◆ LLVMFuzzerTestOneInput()

int LLVMFuzzerTestOneInput ( const uint8_t * data,
size_t size )

Definition at line 352 of file fuzztest.c.

Referenced by main().

+ Here is the call graph for this function:

◆ generate_base_message()

static bool generate_base_message ( uint8_t * buffer,
size_t * msglen )
static

Definition at line 364 of file fuzztest.c.

Referenced by run_iteration().

+ Here is the call graph for this function:

◆ run_iteration()

static void run_iteration ( )
static

Definition at line 393 of file fuzztest.c.

Referenced by main().

+ Here is the call graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 424 of file fuzztest.c.

+ Here is the call graph for this function:

Variable Documentation

◆ g_bufsize

size_t g_bufsize = 256*1024
static

◆ g_sentinel

int g_sentinel
static

Definition at line 142 of file fuzztest.c.

Referenced by do_callback_decode(), field_callback(), and submsg_callback().