Coverage Report

Created: 2025-08-28 06:56

/src/CMake/Tests/Fuzzing/xml_parser_fuzzer.cc
Line
Count
Source (jump to first uncovered line)
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
4
#include <stdint.h>
5
#include <stdio.h>
6
#include <stdlib.h>
7
8
#include "cmXMLParser.h"
9
10
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
11
9.26k
{
12
9.26k
  char test_file[] = "libfuzzer.xml";
13
14
9.26k
  FILE* fp = fopen(test_file, "wb");
15
9.26k
  if (!fp)
16
0
    return 0;
17
9.26k
  fwrite(data, size, 1, fp);
18
9.26k
  fclose(fp);
19
20
9.26k
  cmXMLParser parser;
21
9.26k
  if (!parser.ParseFile(test_file)) {
22
6.21k
    return 1;
23
6.21k
  }
24
25
3.05k
  remove(test_file);
26
3.05k
  return 0;
27
9.26k
}