diff --git a/tests/fuzz/string_fuzzer.c b/tests/fuzz/string_fuzzer.c new file mode 100644 index 00000000..78dfdd43 --- /dev/null +++ b/tests/fuzz/string_fuzzer.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include "../../src/nc_string.c" + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){ + + if(size<3) return 0; + char *new_str = (char *)malloc(size+1); + if (new_str == NULL){ + return 0; + } + memcpy(new_str, data, size); + new_str[size] = '\0'; + + char *new_buffer = (char *)malloc(size+1); + if (new_buffer == NULL){ + free(new_str); + return 0; + } + + _safe_snprintf(new_buffer, size+1, new_str); + + free(new_str); + free(new_buffer); + return 0; +}