mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-07 15:18:38 -06:00
Tests: Add a fuzzer for oss-fuzz
This commit is contained in:
8
Tests/Fuzzing/README.rst
Normal file
8
Tests/Fuzzing/README.rst
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
The fuzzers in this directory are run continuously through OSS-fuzz.
|
||||||
|
All fuzzers are implemented by way of the `libFuzzer engine`_.
|
||||||
|
|
||||||
|
The link to the OSS-fuzz integration can be found here: (pending)
|
||||||
|
All email addresses in the `project.yaml` file on OSS-fuzz will have access
|
||||||
|
to detailed bug reports and will be notified via email if/when bugs are found.
|
||||||
|
|
||||||
|
.. _`libFuzzer Engine`: https://llvm.org/docs/LibFuzzer.html
|
||||||
27
Tests/Fuzzing/xml_parser_fuzzer.cc
Normal file
27
Tests/Fuzzing/xml_parser_fuzzer.cc
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "cmXMLParser.h"
|
||||||
|
|
||||||
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||||
|
{
|
||||||
|
char test_file[] = "libfuzzer.xml";
|
||||||
|
|
||||||
|
FILE* fp = fopen(test_file, "wb");
|
||||||
|
if (!fp)
|
||||||
|
return 0;
|
||||||
|
fwrite(data, size, 1, fp);
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
cmXMLParser parser;
|
||||||
|
if (!parser.ParseFile(test_file)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove(test_file);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user