From 91c8c64423828e02cdb8065ac496b7e88bd163c5 Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Sat, 14 Nov 2020 16:28:00 +0000 Subject: [PATCH] Added fuzzer --- test/fuzzing/fuzz_manifest.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/fuzzing/fuzz_manifest.c diff --git a/test/fuzzing/fuzz_manifest.c b/test/fuzzing/fuzz_manifest.c new file mode 100644 index 00000000..4457fd91 --- /dev/null +++ b/test/fuzzing/fuzz_manifest.c @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include "../../src/common/clib-package.h" + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + if(size<3){ + return 0; + } + char filename[256]; + sprintf(filename, "libfuzzer.json"); + + FILE *fp = fopen(filename, "wb"); + if (!fp) + return 0; + fwrite(data, size, 1, fp); + fclose(fp); + + clib_package_load_from_manifest(filename, 0); + + unlink(filename); + return 0; +}