Skip to content

Commit

Permalink
add etc/libfuzzer-onig.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
kkos committed Aug 28, 2016
1 parent 7b65517 commit 3e65d8b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions etc/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;
}

0 comments on commit 3e65d8b

Please sign in to comment.