From 8069e482edd7a2c57839a8e99b7f8ee30c596d7b Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Thu, 15 Jul 2021 21:03:20 +0100 Subject: [PATCH] add initial fuzzer. --- fuzz/fuzz_union.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 fuzz/fuzz_union.c diff --git a/fuzz/fuzz_union.c b/fuzz/fuzz_union.c new file mode 100644 index 00000000..c759020c --- /dev/null +++ b/fuzz/fuzz_union.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +#include "isl/ctx.h" +#include "isl/union_set.h" + +int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + char* data_cstr = strndup(data, size); + + if (data_cstr == NULL) { + return 0; + } + + isl_ctx* ctx = isl_ctx_alloc(); + isl_union_map_read_from_str(ctx, data_cstr); + isl_union_set_read_from_str(ctx, data_cstr); + + if (size > 10) { + data += 5; + size -= 5; + char *data_cstr2 = strndup(data, size); + + isl_union_set* tmp_set = isl_union_set_read_from_str(ctx, data_cstr); + isl_union_map* tmp_map = isl_union_map_read_from_str(ctx, data_cstr2); + + isl_union_map_intersect_domain(tmp_map, tmp_set); + free(data_cstr2); + } + + isl_ctx_free(ctx); + free(data_cstr); + + return 0; +}