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
readIni(const char * Data,size_t Size)22 readIni(const char* Data, size_t Size)
23 {
24
25 namespace pt = boost::property_tree;
26
27 std::stringstream ss;
28 ss.write(Data, Size);
29
30 pt::ptree tree;
31
32 try {
33 pt::read_ini(ss, tree);
34
35 return tree.size() ? 1 : 0;
36 } catch (...) {
37 return 0;
38 }
39 }
40
41 extern "C" int
LLVMFuzzerTestOneInput(const uint8_t * Data,size_t Size)42 LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size)
43 {
44 readIni(reinterpret_cast<const char*>(Data), Size);
45 return 0;
46 }
47