diff options
author | David Korczynski <david@adalogics.com> | 2023-07-24 04:18:28 -0700 |
---|---|---|
committer | Emanuele Torre <torreemanuele6@gmail.com> | 2023-07-24 13:44:27 +0200 |
commit | cf3c11bde848a0b2a487d78dfcbe5f022d0053ab (patch) | |
tree | ebcdec61e296bf4e68e69c9678f01b9427e0e697 /tests | |
parent | ed334b536fc441fe148d796169b47bda348c812a (diff) |
Add compile fuzzer for OSS-Fuzz
Signed-off-by: David Korczynski <david@adalogics.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/jq_fuzz_compile.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/jq_fuzz_compile.c b/tests/jq_fuzz_compile.c new file mode 100644 index 00000000..91218d6f --- /dev/null +++ b/tests/jq_fuzz_compile.c @@ -0,0 +1,25 @@ +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#include "jq.h" + +int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { + // Creat null-terminated string + char *null_terminated = (char *)malloc(size + 1); + memcpy(null_terminated, (char *)data, size); + null_terminated[size] = '\0'; + + // Fuzzer entrypoint + jq_state *jq = NULL; + jq = jq_init(); + if (jq != NULL) { + jq_compile(jq, null_terminated); + } + jq_teardown(&jq); + + // Free the null-terminated string + free(null_terminated); + + return 0; +} |