Skip to content

Commit

Permalink
Add compile fuzzer for OSS-Fuzz
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski authored and emanuele6 committed Jul 24, 2023
1 parent ed334b5 commit cf3c11b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/jq_fuzz_compile.c
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit cf3c11b

Please sign in to comment.