MCPcopy Create free account
hub / github.com/Kitware/CMake / LLVMFuzzerTestOneInput

Function LLVMFuzzerTestOneInput

Tests/Fuzzing/cmListFileParserFuzzer.cxx:46–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
47{
48 if (size == 0 || size > kMaxInputSize) {
49 return 0;
50 }
51
52 // Write input to temp file
53 std::string testFile = g_testDir + "/CMakeLists.txt";
54 {
55 FILE* fp = fopen(testFile.c_str(), "wb");
56 if (!fp)
57 return 0;
58 fwrite(data, 1, size, fp);
59 fclose(fp);
60 }
61
62 // Create a messenger for error handling
63 cmMessenger messenger;
64
65 // Parse the file
66 cmListFile listFile;
67 cmListFileBacktrace backtrace;
68 if (listFile.ParseFile(testFile.c_str(), &messenger, backtrace)) {
69 // Successfully parsed - examine results
70 for (auto const& func : listFile.Functions) {
71 (void)func.LowerCaseName();
72 (void)func.OriginalName();
73 for (auto const& arg : func.Arguments()) {
74 (void)arg.Value;
75 (void)arg.Delim;
76 }
77 }
78 }
79
80 // Clean up
81 unlink(testFile.c_str());
82
83 return 0;
84}

Callers

nothing calls this directly

Calls 3

c_strMethod · 0.80
ArgumentsMethod · 0.80
ParseFileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…