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

Function LLVMFuzzerTestOneInput

fuzz/fuzz_numeric_parser.cxx:8–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7// Expose the ValueReader class for fuzzing
8extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
9 if (size == 0) return 0;
10
11 // Create a null-terminated string from fuzzer input
12 std::string input(reinterpret_cast<const char*>(data), size);
13
14 // Test numeric parsing with various types
15 args::ValueReader reader;
16
17 // Test signed integer types
18 {
19 int dest_int = 0;
20 reader("fuzz_test", input, dest_int); // Should not crash
21
22 short dest_short = 0;
23 reader("fuzz_test", input, dest_short); // Should not crash
24
25 long long dest_ll = 0;
26 reader("fuzz_test", input, dest_ll); // Should not crash
27 }
28
29 // Test unsigned integer types
30 {
31 unsigned int dest_uint = 0;
32 reader("fuzz_test", input, dest_uint); // Should not crash
33
34 unsigned short dest_ushort = 0;
35 reader("fuzz_test", input, dest_ushort); // Should not crash
36
37 unsigned long long dest_ull = 0;
38 reader("fuzz_test", input, dest_ull); // Should not crash
39 }
40
41 // Test floating point types
42 {
43 float dest_float = 0.0f;
44 reader("fuzz_test", input, dest_float); // Should not crash
45
46 double dest_double = 0.0;
47 reader("fuzz_test", input, dest_double); // Should not crash
48 }
49
50 return 0;
51}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected