Coverage Report

Created: 2023-06-07 06:17

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