test/fuzzer: a simple fuzzer using libFuzzer

This commit adds some basic infrastructure for fuzzers, and adds a
fuzzer for the CUE sheet parser.
This commit is contained in:
Max Kellermann
2020-10-05 19:46:18 +02:00
parent 8358b34efa
commit dffd5831f8
4 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#include "playlist/cue/CueParser.hxx"
#include "util/IterableSplitString.hxx"
#include <string>
#include <string_view>
extern "C" {
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
}
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
CueParser parser;
const std::string_view src{(const char *)data, size};
for (const auto line : IterableSplitString(src, '\n')) {
parser.Feed(std::string(line).c_str());
parser.Get();
}
parser.Finish();
parser.Get();
return 0;
}

9
test/fuzzer/meson.build Normal file
View File

@@ -0,0 +1,9 @@
executable(
'FuzzCueParser',
'FuzzCueParser.cxx',
'../../src/playlist/cue/CueParser.cxx',
include_directories: inc,
dependencies: [
tag_dep,
],
)