diff options
Diffstat (limited to 'contrib/libucl/tests/fuzzers/ucl_add_string_fuzzer.c')
-rw-r--r-- | contrib/libucl/tests/fuzzers/ucl_add_string_fuzzer.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/contrib/libucl/tests/fuzzers/ucl_add_string_fuzzer.c b/contrib/libucl/tests/fuzzers/ucl_add_string_fuzzer.c new file mode 100644 index 000000000000..388ce5dffebb --- /dev/null +++ b/contrib/libucl/tests/fuzzers/ucl_add_string_fuzzer.c @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <errno.h> +#include <unistd.h> +#include "ucl.h" + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + // If size is 0 we need a null-terminated string. + // We dont null-terminate the string and by the design + // of the API passing 0 as size with non null-terminated string + // gives undefined behavior. + if(size==0){ + return 0; + } + struct ucl_parser *parser; + parser = ucl_parser_new(0); + + ucl_parser_add_string(parser, (char *)data, size); + + if (ucl_parser_get_error(parser) != NULL) { + return 0; + } + + ucl_parser_free (parser); + return 0; +} |