infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
fuzz_helpers.c File Reference

Implementation of the shared recursive infix_type generator for fuzzing. More...

#include "fuzz_helpers.h"
Include dependency graph for fuzz_helpers.c:

Functions

infix_typegenerate_random_type (infix_arena_t *arena, fuzzer_input *in, int depth, size_t *total_fields)
 Recursively generates a randomized infix_type from the fuzzer's input data, allocating all objects from the provided arena.
 

Detailed Description

Implementation of the shared recursive infix_type generator for fuzzing.

Copyright (c) 2025 Sanko Robinson

This source code is dual-licensed under the Artistic License 2.0 or the MIT License. You may choose to use this code under the terms of either license.

SPDX-License-Identifier: (Artistic-2.0 OR MIT)

The documentation blocks within this file are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).

SPDX-License-Identifier: CC-BY-4.0

This file contains the implementation of the generate_random_type function, which is the core of the fuzzing strategy. It is designed to be compiled and linked into multiple fuzzing harnesses, providing a consistent and powerful way to generate complex and pathological test cases for the infix library's type system and ABI logic.

Function Documentation

◆ generate_random_type()

infix_type * generate_random_type ( infix_arena_t arena,
fuzzer_input in,
int  depth,
size_t *  total_fields 
)

Recursively generates a randomized infix_type from the fuzzer's input data, allocating all objects from the provided arena.

Parameters
arenaThe arena from which all types and member arrays will be allocated.
inA pointer to the fuzzer input buffer.
depthThe current recursion depth (used to prevent stack overflows).
total_fields[in,out] A pointer to a counter for the total fields generated.
Returns
A new infix_type* allocated within the arena, or NULL on failure.