summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-01-14 18:00:33 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-01-14 18:01:22 (GMT)
commit224956255d24f85ba1ce5d34b0864d8271bff32e (patch)
tree9595e07809912a7599da55f1456bd2a2a6c90284
parent967d1f7dde05769056a6431b7686939ccaa6d86a (diff)
parentb0107165b72afe3e9b72847c350d71af347c856e (diff)
downloadCMake-224956255d24f85ba1ce5d34b0864d8271bff32e.zip
CMake-224956255d24f85ba1ce5d34b0864d8271bff32e.tar.gz
CMake-224956255d24f85ba1ce5d34b0864d8271bff32e.tar.bz2
Merge topic 'fuzz1'
b0107165b7 Tests: Add a fuzzer for oss-fuzz Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5668
-rw-r--r--Tests/Fuzzing/README.rst8
-rw-r--r--Tests/Fuzzing/xml_parser_fuzzer.cc27
2 files changed, 35 insertions, 0 deletions
diff --git a/Tests/Fuzzing/README.rst b/Tests/Fuzzing/README.rst
new file mode 100644
index 0000000..a869f9c
--- /dev/null
+++ b/Tests/Fuzzing/README.rst
@@ -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
diff --git a/Tests/Fuzzing/xml_parser_fuzzer.cc b/Tests/Fuzzing/xml_parser_fuzzer.cc
new file mode 100644
index 0000000..1faa918
--- /dev/null
+++ b/Tests/Fuzzing/xml_parser_fuzzer.cc
@@ -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;
+}