/src/tarantool/test/fuzz/xrow_decode_sql_fuzzer.c
Line | Count | Source |
1 | | #include "box/xrow.h" |
2 | | #include "box/iproto_constants.h" |
3 | | #include "fiber.h" |
4 | | #include "memory.h" |
5 | | |
6 | | void |
7 | 0 | cord_on_yield(void) {} |
8 | | |
9 | | __attribute__((constructor)) |
10 | | static void |
11 | | setup(void) |
12 | 2 | { |
13 | 2 | memory_init(); |
14 | 2 | fiber_init(fiber_c_invoke); |
15 | 2 | } |
16 | | |
17 | | __attribute__((destructor)) |
18 | | static void |
19 | | teardown(void) |
20 | 0 | { |
21 | 0 | fiber_free(); |
22 | 0 | memory_free(); |
23 | 0 | } |
24 | | |
25 | | int |
26 | | LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
27 | 4.94k | { |
28 | 4.94k | const char *d = (const char *)data; |
29 | 4.94k | const char *end = (const char *)data + size; |
30 | 4.94k | if (mp_check(&d, end) != 0) |
31 | 1.46k | return -1; |
32 | | |
33 | 3.48k | struct iovec body = {0}; |
34 | 3.48k | body.iov_base = (void *)data; |
35 | 3.48k | body.iov_len = size; |
36 | | |
37 | 3.48k | struct xrow_header row = {0}; |
38 | 3.48k | row.type = IPROTO_EXECUTE; |
39 | 3.48k | row.body[0] = body; |
40 | 3.48k | row.bodycnt = 1; |
41 | | |
42 | 3.48k | struct sql_request request = {0}; |
43 | 3.48k | if (xrow_decode_sql(&row, &request) == -1) |
44 | 1.14k | return -1; |
45 | | |
46 | 2.34k | return 0; |
47 | 3.48k | } |