/src/fluent-bit/tests/internal/fuzzers/parse_ltsv_fuzzer.c
Line | Count | Source |
1 | | #include <stdint.h> |
2 | | #include <string.h> |
3 | | #include <stdlib.h> |
4 | | #include <fluent-bit/flb_time.h> |
5 | | #include <fluent-bit/flb_parser.h> |
6 | | |
7 | 396 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){ |
8 | 396 | void *out_buf = NULL; |
9 | 396 | size_t out_size = 0; |
10 | 396 | struct flb_time out_time; |
11 | 396 | struct flb_config *fuzz_config; |
12 | 396 | struct flb_parser *fuzz_parser; |
13 | | |
14 | | /* Set fuzzer-malloc chance of failure */ |
15 | 396 | flb_malloc_mod = 25000; |
16 | 396 | flb_malloc_p = 0; |
17 | | |
18 | | /* ltsvc parser */ |
19 | 396 | fuzz_config = flb_config_init(); |
20 | 396 | fuzz_parser = flb_parser_create("fuzzer", "ltsv", NULL, FLB_TRUE, |
21 | 396 | NULL, NULL, NULL, MK_FALSE, |
22 | 396 | MK_TRUE, FLB_FALSE, FLB_FALSE, NULL, 0, |
23 | 396 | NULL, fuzz_config); |
24 | 396 | flb_parser_do(fuzz_parser, (char*)data, size, |
25 | 396 | &out_buf, &out_size, &out_time); |
26 | | |
27 | 396 | if (out_buf != NULL) { |
28 | 358 | free(out_buf); |
29 | 358 | } |
30 | | |
31 | 396 | flb_parser_destroy(fuzz_parser); |
32 | 396 | flb_config_exit(fuzz_config); |
33 | | |
34 | 396 | return 0; |
35 | 396 | } |