summaryrefslogtreecommitdiff
path: root/contributed
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-08-31 03:42:07 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-08-31 03:42:07 +0200
commit75ed3a79bf4fdcb71dd709495de544cb6cef17b3 (patch)
tree67e4b404206c31d3d7d52673c12eb9f756db5c64 /contributed
parentc752981613de81bfa2723749b79e80bf0008f27c (diff)
parenta76fa337cc657dbe669ffb8dbdac606d4d6616f1 (diff)
Merge tag 'upstream/6.1.0'
Upstream version 6.1.0
Diffstat (limited to 'contributed')
-rw-r--r--contributed/libfuzzer-onig.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/contributed/libfuzzer-onig.cpp b/contributed/libfuzzer-onig.cpp
new file mode 100644
index 0000000..984110d
--- /dev/null
+++ b/contributed/libfuzzer-onig.cpp
@@ -0,0 +1,31 @@
+/* libfuzzer test code for oniguruma
+ * author: Hanno Böck, license: CC0/public domain
+
+Usage:
+* compile oniguruma with something like
+ ./configure CC=clang LD=clang CFLAGS="-fsanitize-coverage=edge -fsanitize=address" \
+ LDFLAGS="-fsanitize-coverage=edge -fsanitize=address"
+* Compile libfuzzer stub and link against static libonig.a and libFuzzer.a:
+ clang++ libfuzzer-onig.cpp src/.libs/libonig.a libFuzzer.a -o libfuzzer-onig \
+ -fsanitize-coverage=edge -fsanitize=address
+* Put sample patterns in directory "in/"
+* Run
+ ./libfuzzer-onig in
+
+Consult libfuzzer docs for further details and how to create libFuzzer.a:
+http://llvm.org/docs/LibFuzzer.html
+
+ */
+#include <stdint.h>
+#include <string.h>
+#include <oniguruma.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t * Data, size_t Size)
+{
+ regex_t *reg;
+ if (onig_new
+ (&reg, Data, Data + Size, ONIG_OPTION_DEFAULT, ONIG_ENCODING_UTF8,
+ ONIG_SYNTAX_DEFAULT, 0) == 0)
+ onig_free(reg);
+ return 0;
+}