forked from akheron/jansson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move ossfuzz directory and use Makefile.am
- Loading branch information
Showing
12 changed files
with
99 additions
and
28 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
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
SUBDIRS = bin suites | ||
SUBDIRS = bin suites ossfuzz | ||
EXTRA_DIST = scripts run-suites | ||
|
||
TESTS = run-suites | ||
|
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 @@ | ||
json_load_dump_fuzzer |
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,32 @@ | ||
AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src | ||
LDADD = $(top_builddir)/src/libjansson.la | ||
|
||
if USE_OSSFUZZ_FLAG | ||
FUZZ_FLAG = $(LIB_FUZZING_ENGINE) | ||
else | ||
if USE_OSSFUZZ_STATIC | ||
LDADD += $(LIB_FUZZING_ENGINE) | ||
FUZZ_FLAG = | ||
else | ||
LDADD += libstandaloneengine.a | ||
FUZZ_FLAG = | ||
endif | ||
endif | ||
|
||
noinst_PROGRAMS = | ||
noinst_LIBRARIES = | ||
|
||
if USE_OSSFUZZERS | ||
noinst_PROGRAMS += \ | ||
json_load_dump_fuzzer | ||
|
||
noinst_LIBRARIES += \ | ||
libstandaloneengine.a | ||
endif | ||
|
||
json_load_dump_fuzzer_SOURCES = json_load_dump_fuzzer.cc testinput.h | ||
json_load_dump_fuzzer_CXXFLAGS = $(AM_CXXFLAGS) $(FUZZ_FLAG) | ||
json_load_dump_fuzzer_LDFLAGS = $(AM_LDFLAGS) -static | ||
|
||
libstandaloneengine_a_SOURCES = standaloneengine.cc | ||
libstandaloneengine_a_CXXFLAGS = $(AM_CXXFLAGS) |
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,47 @@ | ||
#include <stdint.h> | ||
#include <sys/types.h> | ||
|
||
#include "jansson.h" | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) | ||
{ | ||
json_error_t error; | ||
|
||
if (size < sizeof(size_t) + sizeof(size_t)) | ||
{ | ||
return 0; | ||
} | ||
|
||
// Use the first sizeof(size_t) bytes as load flags. | ||
size_t load_flags = *(const size_t*)data; | ||
data += sizeof(size_t); | ||
size -= sizeof(size_t); | ||
|
||
// Use the next sizeof(size_t) bytes as dump flags. | ||
size_t dump_flags = *(const size_t*)data; | ||
data += sizeof(size_t); | ||
size -= sizeof(size_t); | ||
|
||
// Attempt to load the remainder of the data with the given load flags. | ||
const char* text = reinterpret_cast<const char *>(data); | ||
json_t* jobj = json_loadb(text, size, load_flags, &error); | ||
|
||
if (jobj == NULL) | ||
{ | ||
return 0; | ||
} | ||
|
||
// Attempt to dump the loaded json object with the given dump flags. | ||
char* out = json_dumps(jobj, dump_flags); | ||
if (out) | ||
{ | ||
free(out); | ||
} | ||
|
||
if (jobj) | ||
{ | ||
json_decref(jobj); | ||
} | ||
|
||
return 0; | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.