Coverage Report

Created: 2023-09-25 06:45

/src/boost_ptree_inforead_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/info_parser.hpp>
19
#include <sstream>
20
21
int
22
readInfo(const char* Data, size_t Size)
23
25
{
24
25
25
  namespace pt = boost::property_tree;
26
27
25
  std::stringstream ss;
28
25
  ss.write(Data, Size);
29
30
25
  pt::ptree tree;
31
32
25
  try {
33
25
    pt::read_info(ss, tree);
34
35
25
    return tree.size() ? 1 : 0;
36
25
  } catch (...) {
37
15
    return 0;
38
15
  }
39
25
}
40
41
extern "C" int
42
LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size)
43
10.3k
{
44
10.3k
  readInfo(reinterpret_cast<const char*>(Data), Size);
45
10.3k
  return 0;
46
10.3k
}