Open
Description
I suggest this fuzzer for continuous vulnerability checks.
/*
* This fuzzer is generated by UTopia with some manual modifications.
* (UTopia Project: https://github.com/Samsung/UTopia)
*/
#include "libconfig.h"
#include <FuzzedDataProvider.h>
#include <fstream>
bool saveFile(std::string Path, std::string Content) {
std::ofstream OFS(Path);
if (!OFS.is_open())
return false;
OFS << Content;
return true;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, uint32_t size) {
config_t cfg;
int ok;
const char *str;
FuzzedDataProvider provider(data, size);
auto Input1 = provider.ConsumeRandomLengthString(10);
auto Input2 = provider.ConsumeRandomLengthString(10);
auto Input3 = provider.ConsumeRemainingBytesAsString();
if (!saveFile("input", Input3))
return 0;
config_init(&cfg);
config_set_include_dir(&cfg, Input1.c_str());
ok = config_read_file(&cfg, "input");
if (!ok) {
config_error_text(&cfg);
config_error_line(&cfg);
}
config_lookup_string(&cfg, Input2.c_str(), &str);
config_destroy(&cfg);
return 0;
}