infix
A JIT-Powered FFI Library for C
|
Shared helper functions and types for infix FFI fuzzing harnesses. More...
#include "common/infix_internals.h"
#include <infix/infix.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
Classes | |
struct | fuzzer_input |
A helper structure to safely consume bytes from the fuzzer's input buffer. More... | |
Macros | |
#define | MAX_RECURSION_DEPTH 32 |
#define | MAX_MEMBERS 16 |
#define | MAX_ARRAY_ELEMENTS 128 |
#define | MAX_TYPES_IN_POOL 16 |
#define | MAX_ARGS_IN_SIGNATURE 16 |
#define | MAX_TOTAL_FUZZ_FIELDS 256 |
#define | DEFINE_CONSUME_T(type) |
A macro to create a type-safe consumer for any given Plain Old Data (POD) type. | |
Functions | |
static const uint8_t * | consume_bytes (fuzzer_input *in, size_t n) |
Safely consume 'n' bytes from the input buffer. | |
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. | |
Shared helper functions and types for infix FFI fuzzing harnesses.
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 header provides the common infrastructure needed to build fuzzers for the infix library, including a structure for managing fuzzer input and a powerful recursive generator for creating complex, randomized infix_type
objects. By centralizing this logic, individual fuzzing harnesses can be kept clean and focused on their specific targets.
#define DEFINE_CONSUME_T | ( | type | ) |
A macro to create a type-safe consumer for any given Plain Old Data (POD) type.
This macro generates a static inline function consume_<type>()
that safely reads bytes from the fuzzer input and copies them into the provided output variable.
#define MAX_ARGS_IN_SIGNATURE 16 |
#define MAX_ARRAY_ELEMENTS 128 |
#define MAX_MEMBERS 16 |
#define MAX_RECURSION_DEPTH 32 |
#define MAX_TOTAL_FUZZ_FIELDS 256 |
#define MAX_TYPES_IN_POOL 16 |
|
inlinestatic |
Safely consume 'n' bytes from the input buffer.
This is a security-critical helper. It checks if enough data is available before advancing the pointer, preventing the fuzzer from reading out of bounds.
in | A pointer to the fuzzer_input struct. |
n | The number of bytes to consume. |
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.
arena | The arena from which all types and member arrays will be allocated. |
in | A pointer to the fuzzer input buffer. |
depth | The current recursion depth (used to prevent stack overflows). |
total_fields | [in,out] A pointer to a counter for the total fields generated. |
infix_type*
allocated within the arena, or NULL on failure.