MCPcopy Create free account
hub / github.com/Taywee/args / LLVMFuzzerTestOneInput

Function LLVMFuzzerTestOneInput

fuzz/commands_fuzzer.cpp:43–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41} // namespace
42
43extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
44{
45 FuzzedDataProvider fdp(data, size);
46
47 // Global options shared by every subcommand (test/global_options.cxx).
48 args::Group globals;
49 args::ValueFlag<std::string> gitdir(globals, "path", "", {"git-dir"});
50 args::HelpFlag help(globals, "help", "help", {"help"});
51
52 args::ArgumentParser parser("commands_fuzzer");
53 args::GlobalOptions globalOptions(parser, globals);
54 args::PositionalList<std::string> paths(parser, "paths", "files", args::Options::Global);
55
56 std::vector<std::string> addPaths;
57 std::vector<std::string> commitInfo;
58 std::vector<std::string> nestedValues;
59
60 args::Command add(parser, "add", "Add file contents to the index", [&](args::Subparser &sp)
61 {
62 args::PositionalList<std::string> list(sp, "paths", "files to add");
63 sp.Parse();
64 addPaths.assign(std::begin(list), std::end(list));
65 });
66
67 args::Command commit(parser, "commit", "Record changes", [&](args::Subparser &sp)
68 {
69 args::Flag amend(sp, "amend", "amend", {'a', "amend"});
70 args::ValueFlag<std::string> message(sp, "message", "message", {'m', "message"});
71 amend.KickOut(true);
72 sp.Parse();
73 if (amend)
74 {
75 (void)amend.Get();
76 }
77 if (message)
78 {
79 commitInfo.emplace_back(*message);
80 }
81 });
82
83 // Nested command: a command created inside another command's subparser.
84 args::Command remote(parser, "remote", "Manage sets of tracked repositories", [&](args::Subparser &sp)
85 {
86 args::Command addRemote(sp, "add", "Add a tracked repository", [&](args::Subparser &sp2)
87 {
88 args::Positional<std::string> name(sp2, "name", "remote name");
89 args::Positional<std::string> url(sp2, "url", "remote url");
90 sp2.Parse();
91 if (name)
92 {
93 nestedValues.emplace_back(*name);
94 }
95 if (url)
96 {
97 nestedValues.emplace_back(*url);
98 }
99 });
100 sp.Parse();

Callers

nothing calls this directly

Calls 1

ArraySizeFunction · 0.70

Tested by

no test coverage detected