Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit a081c87

Browse files
committed
added fuzzer
1 parent fec5aec commit a081c87

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ clean:
3131
mkdir -p $(TARGET_DIR)
3232
mkdir -p $(TARGET_DIR)/gen/nodes
3333
mkdir -p $(TARGET_DIR)/gen/messages
34+
35+
# fuzzer
36+
include fuzzer/build.mk

fuzzer/build.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
target/fuzzer: $(STATIC_LIB) $(HEADER) fuzzer/parse.cpp
2+
$(CXX) fuzzer/parse.cpp -fsanitize=fuzzer,address $(STATIC_LIB) $(CXXFLAGS) $(CXXEXECFLAGS) $(CXX_SET_OUT_FILE)target/fuzzer
3+
4+
fuzz: target/fuzzer
5+
./target/fuzzer -max_len=50 -timeout=10

fuzzer/parse.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdint.h>
2+
#include <stddef.h>
3+
#include <string>
4+
5+
#include "../target/lib-ruby-parser.h"
6+
7+
using namespace lib_ruby_parser;
8+
9+
extern "C" int LLVMFuzzerTestOneInput(char *data, size_t size)
10+
{
11+
std::string input(data, size);
12+
auto result = ParserResult::from_source(Bytes(input), ParserOptions());
13+
return 0;
14+
}

0 commit comments

Comments
 (0)