MCPcopy Create free account
hub / github.com/CLIUtils/CLI11 / LLVMFuzzerTestOneInput

Function LLVMFuzzerTestOneInput

fuzz/cli11_file_fuzz.cpp:14–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include <string>
13
14extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
15 if(Size == 0) {
16 return 0;
17 }
18 std::string parseString(reinterpret_cast<const char *>(Data), Size);
19 std::stringstream out(parseString);
20 CLI::FuzzApp fuzzdata;
21
22 auto app = fuzzdata.generateApp();
23 try {
24 app->parse_from_stream(out);
25 // should be able to write the config to a file and read from it again
26 std::string configOut = app->config_to_str();
27
28 app->clear();
29 std::stringstream out(configOut);
30 app->parse_from_stream(out);
31 } catch(const CLI::HorribleError &he) {
32 throw;
33 } catch(const CLI::ParseError &e) {
34 // (app)->exit(e);
35 // this just indicates we caught an error known by CLI
36 }
37
38 return 0; // Non-zero return values are reserved for future use.
39}

Callers

nothing calls this directly

Calls 3

generateAppMethod · 0.80
parse_from_streamMethod · 0.80
clearMethod · 0.80

Tested by

no test coverage detected