summaryrefslogtreecommitdiffhomepage
path: root/oss-fuzz
diff options
context:
space:
mode:
authorBhargava Shastry <[email protected]>2018-12-05 17:45:27 +0100
committerBhargava Shastry <[email protected]>2018-12-05 17:45:27 +0100
commit1d1b47044c7ead3a629a6c8979a5ce1bf81c65b1 (patch)
tree394bf7daac4ce2a894f9b0e872aef8c3fb909371 /oss-fuzz
parente6bad6766a8ddc00c23b1c0204b047dfbf8e3041 (diff)
downloadmruby-1d1b47044c7ead3a629a6c8979a5ce1bf81c65b1.tar.gz
mruby-1d1b47044c7ead3a629a6c8979a5ce1bf81c65b1.zip
ossfuzz: Add simple mruby compile test harness
Diffstat (limited to 'oss-fuzz')
-rw-r--r--oss-fuzz/mruby_fuzzer.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/oss-fuzz/mruby_fuzzer.c b/oss-fuzz/mruby_fuzzer.c
new file mode 100644
index 000000000..9d3d44a5b
--- /dev/null
+++ b/oss-fuzz/mruby_fuzzer.c
@@ -0,0 +1,18 @@
+#include <stdlib.h>
+#include <string.h>
+#include <mruby.h>
+#include <mruby/compile.h>
+
+int LLVMFuzzerTestOneInput(uint8_t *Data, size_t size) {
+ if (size < 1) {
+ return 0;
+ }
+ char *code = malloc(size+1);
+ memcpy(code, Data, size);
+ code[size] = '\0';
+ mrb_state *mrb = mrb_open();
+ mrb_load_string(mrb, code);
+ mrb_close(mrb);
+ free(code);
+ return 0;
+}