/src/libucl/tests/fuzzers/ucl_add_string_fuzzer.c
Line | Count | Source |
1 | | #include <stdio.h> |
2 | | #include <errno.h> |
3 | | #include <unistd.h> |
4 | | #include "ucl.h" |
5 | | |
6 | 634 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
7 | | // If size is 0 we need a null-terminated string. |
8 | | // We dont null-terminate the string and by the design |
9 | | // of the API passing 0 as size with non null-terminated string |
10 | | // gives undefined behavior. |
11 | 634 | if(size==0){ |
12 | 0 | return 0; |
13 | 0 | } |
14 | 634 | struct ucl_parser *parser; |
15 | 634 | parser = ucl_parser_new(0); |
16 | | |
17 | 634 | ucl_parser_add_string(parser, (char *)data, size); |
18 | | |
19 | 634 | if (ucl_parser_get_error(parser) != NULL) { |
20 | 593 | return 0; |
21 | 593 | } |
22 | | |
23 | 41 | ucl_parser_free (parser); |
24 | 41 | return 0; |
25 | 634 | } |