/src/tarantool/test/fuzz/xrow_header_decode_fuzzer.c
Line | Count | Source |
1 | | #include "box/iproto_constants.h" |
2 | | #include "box/xrow.h" |
3 | | #include "box/error.h" |
4 | | #include "memory.h" |
5 | | |
6 | | void |
7 | 0 | cord_on_yield(void) {} |
8 | | |
9 | | static void |
10 | | fuzz_check_on_error(const struct mp_check_error *mperr) |
11 | 546 | { |
12 | | /* Dummy error. */ |
13 | 546 | diag_set(ClientError, ER_INVALID_MSGPACK, "dummy"); |
14 | 546 | } |
15 | | |
16 | | __attribute__((constructor)) |
17 | | static void |
18 | | setup(void) |
19 | 2 | { |
20 | 2 | mp_check_on_error = fuzz_check_on_error; |
21 | 2 | memory_init(); |
22 | 2 | } |
23 | | |
24 | | __attribute__((destructor)) |
25 | | static void |
26 | | teardown(void) |
27 | 0 | { |
28 | 0 | memory_free(); |
29 | 0 | } |
30 | | |
31 | | int |
32 | | LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
33 | 5.43k | { |
34 | 5.43k | const char *p = (const char *)data; |
35 | 5.43k | const char *pe = (const char *)data + size; |
36 | 5.43k | if (mp_check(&p, pe) != 0) |
37 | 1.37k | return -1; |
38 | | |
39 | 4.05k | struct xrow_header header; |
40 | 4.05k | xrow_decode(&header, &p, pe, false); |
41 | | |
42 | 4.05k | return 0; |
43 | 5.43k | } |