-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: David Korczynski <david@adalogics.com>
- Loading branch information
1 parent
8a4f246
commit 97c6d28
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
#include "jv.h" | ||
|
||
int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { | ||
// Create file with fuzzer data | ||
char filename[256]; | ||
sprintf(filename, "/tmp/libfuzzer.%d", getpid()); | ||
FILE *fp = fopen(filename, "wb"); | ||
if (!fp) { | ||
return 0; | ||
} | ||
fwrite(data, size, 1, fp); | ||
fclose(fp); | ||
|
||
// Fuzz the two version of jv_load_file | ||
jv data1 = jv_load_file(filename, 1); | ||
jv_free(data1); | ||
jv data2 = jv_load_file(filename, 0); | ||
jv_free(data2); | ||
|
||
// Clean up fuzz file | ||
unlink(filename); | ||
|
||
return 0; | ||
} |