summaryrefslogtreecommitdiffstats
path: root/fluent-bit/tests/internal/fuzzers/msgpack_parse_fuzzer.c
blob: cbf2ecf1484e211816b3566290d62bc3e837fa7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdint.h>
#include <stdlib.h>
#include <msgpack.h>
#include <fluent-bit/flb_pack.h>

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){
    /* Set flb_malloc_mod to be fuzzer-data dependent */
    if (size < 4) {
        return 0;
    }
    flb_malloc_p = 0;
    flb_malloc_mod = *(int*)data;
    data += 4;
    size -= 4;

    /* Avoid division by zero for modulo operations */
    if (flb_malloc_mod == 0) {
        flb_malloc_mod = 1;
    }

    if (size != 512)
        return 0;

    /* target the conversion of raw msgpack to json */
    flb_sds_t record;
    record = flb_msgpack_raw_to_json_sds(data, size);
    flb_sds_destroy(record);

    return 0;
}