Add fuzzing infrastructure

This commit adds the --enable-fuzzing (and --enable-asan, to make
fuzzing more useful) options and a sample fuzzer for the terminal
parser. At this time only libfuzzer is supported. Future changes to
add AFL to get more fuzzing capability should be possible with the
addition of the afl_driver.cc from Chromium.
This commit is contained in:
Alex Chernyakhovsky
2022-05-30 20:00:04 -04:00
committed by Alex Chernyakhovsky
parent 1f27c532ac
commit 0c6e034459
14 changed files with 67 additions and 1 deletions
+7
View File
@@ -0,0 +1,7 @@
AM_CXXFLAGS = $(WARNING_CXXFLAGS) $(PICKY_CXXFLAGS) $(HARDEN_CFLAGS) $(MISC_CXXFLAGS) $(CODE_COVERAGE_CXXFLAGS) $(FUZZING_CFLAGS)
noinst_PROGRAMS = terminal_parser_fuzzer
terminal_parser_fuzzer_CPPFLAGS = -I$(srcdir)/../terminal -I$(srcdir)/../util
terminal_parser_fuzzer_LDADD = ../terminal/libmoshterminal.a ../util/libmoshutil.a
terminal_parser_fuzzer_SOURCES = terminal_parser_fuzzer.cc
@@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
+15
View File
@@ -0,0 +1,15 @@
#include <cstddef>
#include <cstdint>
#include "parser.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
Parser::UTF8Parser parser;
Parser::Actions result;
for (size_t i = 0; i < size; i++) {
parser.input(data[i], result);
}
return 0;
}