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