https://github.com/Kitware/CMake
Raw File
Tip revision: c3977582b77f8b5a4ccacf460a262ff0a75d3cc5 authored by Brad King on 23 August 2023, 13:25:28 UTC
CMake 3.27.4
Tip revision: c397758
xml_parser_fuzzer.cc
/* 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;
}
back to top