Skip to content

Commit

Permalink
test: add jv_dump to extended fuzzer
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 Nov 28, 2023
1 parent 44300e4 commit eb3b565
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/jq_fuzz_parse_extended.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
#include "jv.h"

int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
if (size < 4) {
if (size < 8) {
return 0;
}

int fuzz_flags = *(int*)data;
data += 4;
size -= 4;
int dump_flags = *(int*)data;
data += 4;
size -= 4;

// Creat null-terminated string
char *null_terminated = (char *)malloc(size + 1);
Expand All @@ -20,6 +23,9 @@ int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {

// Fuzzer entrypoint
jv res = jv_parse_custom_flags(null_terminated, fuzz_flags);
if (jv_is_valid(res)) {
jv_dump(res, dump_flags);
}
jv_free(res);

// Free the null-terminated string
Expand Down

0 comments on commit eb3b565

Please sign in to comment.