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:
26
test/fuzzer/FuzzCueParser.cxx
Normal file
26
test/fuzzer/FuzzCueParser.cxx
Normal 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
9
test/fuzzer/meson.build
Normal file
@@ -0,0 +1,9 @@
|
||||
executable(
|
||||
'FuzzCueParser',
|
||||
'FuzzCueParser.cxx',
|
||||
'../../src/playlist/cue/CueParser.cxx',
|
||||
include_directories: inc,
|
||||
dependencies: [
|
||||
tag_dep,
|
||||
],
|
||||
)
|
Reference in New Issue
Block a user