Added check for temp file existance

This commit is contained in:
BoloniniD 2021-05-26 00:58:49 +03:00
parent 6a434c0ce8
commit 1fbcfd9c6a
2 changed files with 18 additions and 208 deletions

View File

@ -1,26 +1,34 @@
#include <iostream>
#include <fstream>
#include <string>
#include <Parsers/ASTCreateQuery.h>
#include <Parsers/ParserCreateQuery.h>
#include <Parsers/formatAST.h>
#include <Parsers/parseQuery.h>
#include <time.h>
#include <filesystem>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
{
/// How to test:
/// build ClickHouse with YAML_fuzzer.cpp
/// ./YAML_fuzzer YAML_CORPUS
/// where YAML_CORPUS is a directory with different YAML configs for libfuzzer
srand(time(NULL));
std::string cur_file = std::to_string(rand());
while (std::filesystem::exists(cur_file))
{
std::string cur_file = std::to_string(rand());
}
std::string input = std::string(reinterpret_cast<const char*>(data), size);
DB::YAMLParser parser;
std::ofstream temp_file("YAML_fuzzer_data.yaml");
std::ofstream temp_file(cur_file);
temp_file << input;
temp_file.close();
YAMLParser::parse("YAML_fuzzer_data.yaml");
remove("YAML_fuzzer_data.yaml");
DB::YAMLParser::parse(cur_file);
remove(cur_file.c_str());
return 0;
}

View File

@ -1,198 +0,0 @@
"key1"
"key2"
"key3"
"key4"
"key5"
"key6"
"key7"
"key8"
"key9"
"key10"
"key11"
"key12"
"key13"
"key14"
"key15"
"key16"
"key17"
"key18"
"key19"
"key20"
"key21"
"key22"
"key23"
"key24"
"key25"
"key26"
"key27"
"key28"
"key29"
"key30"
"key31"
"key32"
"key33"
"key34"
"key35"
"key36"
"key37"
"key38"
"key39"
"key40"
"key41"
"key42"
"key43"
"key44"
"key45"
"key46"
"key47"
"key48"
"key49"
"key50"
"key51"
"key52"
"key53"
"key54"
"key55"
"key56"
"key57"
"key58"
"key59"
"key60"
"key61"
"key62"
"key63"
"key64"
"key65"
"key66"
"key67"
"key68"
"key69"
"key70"
"key71"
"key72"
"key73"
"key74"
"key75"
"key76"
"key77"
"key78"
"key79"
"key80"
"key81"
"key82"
"key83"
"key84"
"key85"
"key86"
"key87"
"key88"
"key89"
"key90"
"key91"
"key92"
"key93"
"key94"
"key95"
"key96"
"key97"
"key98"
"key99"
"val1"
"val2"
"val3"
"val4"
"val5"
"val6"
"val7"
"val8"
"val9"
"val10"
"val11"
"val12"
"val13"
"val14"
"val15"
"val16"
"val17"
"val18"
"val19"
"val20"
"val21"
"val22"
"val23"
"val24"
"val25"
"val26"
"val27"
"val28"
"val29"
"val30"
"val31"
"val32"
"val33"
"val34"
"val35"
"val36"
"val37"
"val38"
"val39"
"val40"
"val41"
"val42"
"val43"
"val44"
"val45"
"val46"
"val47"
"val48"
"val49"
"val50"
"val51"
"val52"
"val53"
"val54"
"val55"
"val56"
"val57"
"val58"
"val59"
"val60"
"val61"
"val62"
"val63"
"val64"
"val65"
"val66"
"val67"
"val68"
"val69"
"val70"
"val71"
"val72"
"val73"
"val74"
"val75"
"val76"
"val77"
"val78"
"val79"
"val80"
"val81"
"val82"
"val83"
"val84"
"val85"
"val86"
"val87"
"val88"
"val89"
"val90"
"val91"
"val92"
"val93"
"val94"
"val95"
"val96"
"val97"
"val98"
"val99"