/src/fluent-bit/tests/internal/fuzzers/msgpack_parse_fuzzer.c
Line | Count | Source |
1 | | #include <stdint.h> |
2 | | #include <stdlib.h> |
3 | | #include <msgpack.h> |
4 | | #include <fluent-bit/flb_pack.h> |
5 | | |
6 | 752 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){ |
7 | | /* Set flb_malloc_mod to be fuzzer-data dependent */ |
8 | 752 | if (size < 4) { |
9 | 2 | return 0; |
10 | 2 | } |
11 | 750 | flb_malloc_p = 0; |
12 | 750 | flb_malloc_mod = *(int*)data; |
13 | 750 | data += 4; |
14 | 750 | size -= 4; |
15 | | |
16 | | /* Avoid division by zero for modulo operations */ |
17 | 750 | if (flb_malloc_mod == 0) { |
18 | 3 | flb_malloc_mod = 1; |
19 | 3 | } |
20 | | |
21 | 750 | if (size != 512) |
22 | 94 | return 0; |
23 | | |
24 | | /* target the conversion of raw msgpack to json */ |
25 | 656 | flb_sds_t record; |
26 | 656 | record = flb_msgpack_raw_to_json_sds(data, size); |
27 | 656 | flb_sds_destroy(record); |
28 | | |
29 | 656 | return 0; |
30 | 750 | } |