Skip to content
Myr

jq_fuzz_parse_extended.c

This file

Path

tests/jq_fuzz_parse_extended.c

36 lines · 708 bytes · C

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than fa6a2ff point at it.

website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff

lines 1–36why, one step back
1#include <stdint.h>
2#include <stdlib.h>3#include <string.h>45#include "jv.h"67int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {8 if (size < 8) {9 return 0;10 }1112 int fuzz_flags = *(int*)data;13 data += 4;14 size -= 4;15 int dump_flags = *(int*)data;16 data += 4;17 size -= 4;1819 // Creat null-terminated string20 char *null_terminated = (char *)malloc(size + 1);21 memcpy(null_terminated, (char *)data, size);22 null_terminated[size] = '\0';2324 // Fuzzer entrypoint25 jv res = jv_parse_custom_flags(null_terminated, fuzz_flags);26 if (jv_is_valid(res)) {27 jv_dump(res, dump_flags);28 } else {29 jv_free(res);30 }3132 // Free the null-terminated string33 free(null_terminated);3435 return 0;36}