mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
test: add jv_dump to extended fuzzer
Signed-off-by: David Korczynski <david@adalogics.com>
This commit is contained in:
committed by
Emanuele Torre
parent
44300e4310
commit
eb3b5654bb
@ -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);
|
||||
@ -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
|
||||
|
Reference in New Issue
Block a user