Skip to content
Myr

Add compile fuzzer for OSS-Fuzz

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Korczynski · committed by Emanuele Torre · parent ed334b5 · Browse files · 1 file+25 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Signed-off-by: David Korczynski <david@adalogics.com>

Diff stats

1 file+25 added−0 removed

  • tests:+25 added−0 removed

1 file+25 added−0 removed

added:tests/jq_fuzz_compile.c+25 added
1#include <stdint.h>2#include <stdlib.h>3#include <string.h>45#include "jq.h"67int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {8 // Creat null-terminated string9 char *null_terminated = (char *)malloc(size + 1);10 memcpy(null_terminated, (char *)data, size);11 null_terminated[size] = '\0';1213 // Fuzzer entrypoint14 jq_state *jq = NULL;15 jq = jq_init();16 if (jq != NULL) {17 jq_compile(jq, null_terminated);18 }19 jq_teardown(&jq);2021 // Free the null-terminated string22 free(null_terminated);2324 return 0;25}