Coverage Report

Created: 2024-07-27 06:44

/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 Copyright.txt 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(const uint8_t* data, size_t size)
11
10.0k
{
12
10.0k
  char test_file[] = "libfuzzer.xml";
13
14
10.0k
  FILE* fp = fopen(test_file, "wb");
15
10.0k
  if (!fp)
16
0
    return 0;
17
10.0k
  fwrite(data, size, 1, fp);
18
10.0k
  fclose(fp);
19
20
10.0k
  cmXMLParser parser;
21
10.0k
  if (!parser.ParseFile(test_file)) {
22
7.91k
    return 1;
23
7.91k
  }
24
25
2.11k
  remove(test_file);
26
2.11k
  return 0;
27
10.0k
}