Skip to content
Myr

jq_fuzz_load_file.c

This file

Path

tests/jq_fuzz_load_file.c

28 lines · 572 bytes · C

Last changed by

Not known.

History of this file

Take it

1#include <stdint.h>2#include <stdlib.h>3#include <unistd.h>45#include "jv.h"67int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {8  // Create file with fuzzer data9  char filename[256];10  sprintf(filename, "/tmp/libfuzzer.%d", getpid());11  FILE *fp = fopen(filename, "wb");12  if (!fp) {13    return 0;14  }15  fwrite(data, size, 1, fp);16  fclose(fp);1718  // Fuzz the two version of jv_load_file19  jv data1 = jv_load_file(filename, 1);20  jv_free(data1);21  jv data2 = jv_load_file(filename, 0);22  jv_free(data2);2324  // Clean up fuzz file25  unlink(filename);2627  return 0;28}