Coverage Report

Created: 2025-01-26 06:54

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