diff options
Diffstat (limited to 'contributed')
-rw-r--r-- | contributed/libfuzzer-onig.cpp | 18 | ||||
-rw-r--r-- | contributed/makefile | 22 |
2 files changed, 37 insertions, 3 deletions
diff --git a/contributed/libfuzzer-onig.cpp b/contributed/libfuzzer-onig.cpp index 984110d..dcd7c63 100644 --- a/contributed/libfuzzer-onig.cpp +++ b/contributed/libfuzzer-onig.cpp @@ -23,9 +23,21 @@ http://llvm.org/docs/LibFuzzer.html extern "C" int LLVMFuzzerTestOneInput(const uint8_t * Data, size_t Size) { regex_t *reg; - if (onig_new - (®, Data, Data + Size, ONIG_OPTION_DEFAULT, ONIG_ENCODING_UTF8, - ONIG_SYNTAX_DEFAULT, 0) == 0) + OnigEncoding enc; + + enc = ONIG_ENCODING_UTF8; + +#ifdef FULL_TEST + onig_initialize(&enc, 1); +#endif + + if (onig_new(®, Data, Data + Size, ONIG_OPTION_DEFAULT, enc, + ONIG_SYNTAX_DEFAULT, 0) == 0) onig_free(reg); + +#ifdef FULL_TEST + onig_end(); +#endif + return 0; } diff --git a/contributed/makefile b/contributed/makefile new file mode 100644 index 0000000..c50ab36 --- /dev/null +++ b/contributed/makefile @@ -0,0 +1,22 @@ + +ONIG_LIB=../src/.libs/libonig.a +LIBS=$(ONIG_LIB) /usr/local/lib/libLLVMFuzzerMain.a + +TARGETS=libfuzzer-onig libfuzzer-onig-full + +default: $(TARGETS) + +libfuzzer-onig: libfuzzer-onig.cpp $(ONIG_LIB) + clang++ $< $(LIBS) -o $@ -fsanitize-coverage=trace-pc-guard -fsanitize=fuzzer,address + +libfuzzer-onig-full: libfuzzer-onig.cpp $(ONIG_LIB) + clang++ -DFULL_TEST $< $(LIBS) -o $@ -fsanitize-coverage=trace-pc-guard -fsanitize=fuzzer,address + + +$(ONIG_LIB): + cd ..; ./configure CC=clang LD=clang CFLAGS="-g -fsanitize=fuzzer,address" LDFLAGS="-fsanitize-coverage=trace-pc-guard -fsanitize=fuzzer,address"; make + + + +clean: + rm -f $(TARGETS) |