/src/tarantool/test/fuzz/csv_fuzzer.c
Line | Count | Source |
1 | | #include <stdint.h> |
2 | | #include <stdlib.h> |
3 | | #include <stddef.h> |
4 | | #include <string.h> |
5 | | #include "csv/csv.h" |
6 | | |
7 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
8 | 15.1k | { |
9 | 15.1k | struct csv csv; |
10 | 15.1k | csv_create(&csv); |
11 | 15.1k | char *buf = calloc(size + 1, sizeof(char)); |
12 | 15.1k | if (buf == NULL) |
13 | 0 | return 0; |
14 | 15.1k | memcpy(buf, data, size); |
15 | 15.1k | buf[size] = '\0'; |
16 | 15.1k | char *end = buf + size; |
17 | 15.1k | csv_parse_chunk(&csv, buf, end); |
18 | 15.1k | csv_finish_parsing(&csv); |
19 | 15.1k | csv_destroy(&csv); |
20 | 15.1k | free(buf); |
21 | | |
22 | 15.1k | return 0; |
23 | 15.1k | } |