/src/boost_ptree_iniread_fuzzer.cc
Line | Count | Source |
1 | | /* |
2 | | * Fuzzing of boost property tree parsers. |
3 | | * by Paul Dreik 20180818 |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | */ |
17 | | |
18 | | #include <boost/property_tree/ini_parser.hpp> |
19 | | #include <sstream> |
20 | | |
21 | | int |
22 | | readIni(const char* Data, size_t Size) |
23 | 901 | { |
24 | | |
25 | 901 | namespace pt = boost::property_tree; |
26 | | |
27 | 901 | std::stringstream ss; |
28 | 901 | ss.write(Data, Size); |
29 | | |
30 | 901 | pt::ptree tree; |
31 | | |
32 | 901 | try { |
33 | 901 | pt::read_ini(ss, tree); |
34 | | |
35 | 901 | return tree.size() ? 1 : 0; |
36 | 901 | } catch (...) { |
37 | 164 | return 0; |
38 | 164 | } |
39 | 901 | } |
40 | | |
41 | | extern "C" int |
42 | | LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) |
43 | 10.3k | { |
44 | 10.3k | readIni(reinterpret_cast<const char*>(Data), Size); |
45 | 10.3k | return 0; |
46 | 10.3k | } |