| 21 | "threshold", "max_repeats" }; |
| 22 | |
| 23 | std::string generateFuzzedNodeXML(FuzzedDataProvider& fdp, int depth = 0) |
| 24 | { |
| 25 | // Prevent stack overflow with max depth |
| 26 | if(depth > 6) |
| 27 | { // Reasonable limit for XML tree depth |
| 28 | return "<AlwaysSuccess/>"; |
| 29 | } |
| 30 | |
| 31 | std::string xml; |
| 32 | const std::string node_type = fdp.PickValueInArray(NODE_TYPES); |
| 33 | |
| 34 | xml += "<" + node_type; |
| 35 | |
| 36 | size_t num_attributes = fdp.ConsumeIntegralInRange<size_t>(0, 3); |
| 37 | for(size_t i = 0; i < num_attributes; i++) |
| 38 | { |
| 39 | const std::string attr = fdp.PickValueInArray(NODE_ATTRIBUTES); |
| 40 | std::string value = fdp.ConsumeRandomLengthString(10); |
| 41 | xml += " " + attr + "=\"" + value + "\""; |
| 42 | } |
| 43 | |
| 44 | if(depth > 3 || fdp.ConsumeBool()) |
| 45 | { |
| 46 | xml += "/>"; |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | xml += ">"; |
| 51 | // Add some child nodes recursively with depth limit |
| 52 | size_t num_children = fdp.ConsumeIntegralInRange<size_t>(0, 2); |
| 53 | for(size_t i = 0; i < num_children; i++) |
| 54 | { |
| 55 | xml += generateFuzzedNodeXML(fdp, depth + 1); |
| 56 | } |
| 57 | xml += "</" + node_type + ">"; |
| 58 | } |
| 59 | |
| 60 | return xml; |
| 61 | } |
| 62 | |
| 63 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) |
| 64 | { |
no outgoing calls
no test coverage detected