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

Function LLVMFuzzerTestOneInput

Tests/Fuzzing/cmListFileLexerFuzzer.cxx:26–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24static constexpr size_t kMaxInputSize = 64 * 1024; // 64KB
25
26extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
27{
28 // Skip overly large inputs
29 if (size == 0 || size > kMaxInputSize) {
30 return 0;
31 }
32
33 cmListFileLexer* lexer = cmListFileLexer_New();
34 if (!lexer) {
35 return 0;
36 }
37
38 // Parse from string (not file) for efficiency
39 if (cmListFileLexer_SetString(lexer, reinterpret_cast<char const*>(data),
40 size)) {
41 // Consume all tokens until EOF or error
42 cmListFileLexer_Token* token;
43 while ((token = cmListFileLexer_Scan(lexer)) != nullptr) {
44 // Access token fields to ensure they're valid
45 (void)token->type;
46 (void)token->text;
47 (void)token->length;
48 (void)token->line;
49 (void)token->column;
50
51 // Get type as string for additional coverage
52 (void)cmListFileLexer_GetTypeAsString(lexer, token->type);
53 }
54
55 // Exercise position tracking
56 (void)cmListFileLexer_GetCurrentLine(lexer);
57 (void)cmListFileLexer_GetCurrentColumn(lexer);
58 }
59
60 cmListFileLexer_Delete(lexer);
61 return 0;
62}

Callers

nothing calls this directly

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…