Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2023 Emweb bv, Herent, Belgium. |
3 | | * |
4 | | * See the LICENSE file for terms of use. |
5 | | */ |
6 | | |
7 | | #include <stdint.h> |
8 | | #include <stddef.h> |
9 | | #include <string> |
10 | | |
11 | | #include "web/WebUtils.h" |
12 | | #include "thirdparty/rapidxml/rapidxml.hpp" |
13 | | #include "thirdparty/rapidxml/rapidxml_print.hpp" |
14 | | #include <vector> |
15 | | |
16 | 4.95k | #define kMinInputLength 10 |
17 | 2.47k | #define kMaxInputLength 5120 |
18 | | |
19 | 2.47k | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
20 | | |
21 | 2.47k | if (Size < kMinInputLength || Size > kMaxInputLength) { |
22 | 22 | return 1; |
23 | 22 | } |
24 | | |
25 | 2.45k | std::string data(Data, Data + Size); |
26 | 2.45k | std::vector<char> text(data.begin(), data.end()); |
27 | 2.45k | text.push_back('\0'); |
28 | | |
29 | 2.45k | try { |
30 | 2.45k | Wt::rapidxml::xml_document<> doc; |
31 | 2.45k | doc.parse<0>(&text[0]); |
32 | 2.45k | Wt::Utils::fixSelfClosingTags(&doc); |
33 | 2.45k | } catch( ... ) {/*...*/} |
34 | | |
35 | 2.45k | return 0; |
36 | 2.45k | } |