xml_parser_fuzzer.cc 568 B

123456789101112131415161718192021222324252627
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include <stdint.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include "cmXMLParser.h"
  7. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
  8. {
  9. char test_file[] = "libfuzzer.xml";
  10. FILE* fp = fopen(test_file, "wb");
  11. if (!fp)
  12. return 0;
  13. fwrite(data, size, 1, fp);
  14. fclose(fp);
  15. cmXMLParser parser;
  16. if (!parser.ParseFile(test_file)) {
  17. return 1;
  18. }
  19. remove(test_file);
  20. return 0;
  21. }