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

Function LLVMFuzzerTestOneInput

Tests/Fuzzing/cmStringAlgorithmsFuzzer.cxx:20–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18static constexpr size_t kMaxInputSize = 16 * 1024;
19
20extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
21{
22 if (size == 0 || size > kMaxInputSize) {
23 return 0;
24 }
25
26 std::string input(reinterpret_cast<char const*>(data), size);
27
28 // Test string manipulation functions
29 (void)cmTrimWhitespace(input);
30 (void)cmRemoveQuotes(input);
31 (void)cmEscapeQuotes(input);
32
33 // Test case conversion
34 (void)cmSystemTools::UpperCase(input);
35 (void)cmSystemTools::LowerCase(input);
36
37 // Test tokenization
38 std::vector<std::string> tokens = cmTokenize(input, " \t\n\r");
39 (void)tokens.size();
40
41 // Test with different separators if input is large enough
42 if (size > 4) {
43 std::string sep(reinterpret_cast<char const*>(data), 2);
44 std::string str(reinterpret_cast<char const*>(data + 2), size - 2);
45 std::vector<std::string> parts = cmTokenize(str, sep);
46 (void)parts.size();
47 }
48
49 // Test join operations
50 if (!tokens.empty()) {
51 (void)cmJoin(tokens, ";");
52 (void)cmJoin(tokens, ",");
53 }
54
55 // Test string contains
56 if (size > 2) {
57 std::string haystack(reinterpret_cast<char const*>(data), size / 2);
58 std::string needle(reinterpret_cast<char const*>(data + size / 2),
59 size - size / 2);
60 (void)cmHasPrefix(haystack, needle);
61 (void)cmHasSuffix(haystack, needle);
62 }
63
64 // Test path operations
65 (void)cmSystemTools::GetFilenameWithoutExtension(input);
66 (void)cmSystemTools::GetFilenameExtension(input);
67 (void)cmSystemTools::GetFilenameName(input);
68 (void)cmSystemTools::GetFilenameLastExtension(input);
69 (void)cmSystemTools::GetFilenamePath(input);
70
71 // Test path normalization
72 (void)cmSystemTools::CollapseFullPath(input);
73
74 return 0;
75}

Callers

nothing calls this directly

Calls 9

cmTrimWhitespaceFunction · 0.85
cmRemoveQuotesFunction · 0.85
cmEscapeQuotesFunction · 0.85
cmTokenizeFunction · 0.85
cmHasPrefixFunction · 0.85
cmHasSuffixFunction · 0.85
cmJoinFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…