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