first commit
CI / Build (clang, clang++, ubuntu-22.04, linux, 3.10, master, x86,x86_64) (push) Canceled after 0s
CI / Build (clang, clang++, windows-2022, windows, 3.10, master, x86,x86_64) (push) Canceled after 0s
CI / Release (push) Canceled after 0s

This commit is contained in:
2026-09-13 22:18:11 +01:00
commit 08c03ac533
6701 changed files with 1577314 additions and 0 deletions
@@ -0,0 +1,44 @@
#include <string>
#include <iostream>
#include <fstream>
#include <mruby.h>
#include <mruby/compile.h>
#include "libprotobuf-mutator/src/libfuzzer/libfuzzer_macro.h"
#include "ruby.pb.h"
#include "proto_to_ruby.h"
using namespace ruby_fuzzer;
using namespace std;
int FuzzRB(const uint8_t *Data, size_t size) {
mrb_value v;
mrb_state *mrb = mrb_open();
if (!mrb)
return 0;
char *code = (char *)malloc(size+1);
if (!code)
return 0;
memcpy(code, Data, size);
code[size] = '\0';
if (const char *dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) {
// With libFuzzer binary run this to generate an RB file x.rb:
// PROTO_FUZZER_DUMP_PATH=x.rb ./a.out proto-input
std::ofstream of(dump_path);
of.write(code, size);
}
v = mrb_load_string(mrb, code);
mrb_close(mrb);
free(code);
return 0;
}
DEFINE_PROTO_FUZZER(const Function &function) {
protoConverter converter;
auto s = converter.FunctionToString(function);
(void)FuzzRB((const uint8_t*)s.data(), s.size());
}