// Fuzz target for the config parser.
#include "conf.h"
#include "platform.h"
#include <fcntl.h>
#include <stdint.h>
static Conf conf;
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
static int sink = -1;
if (sink < 0) sink = sys_open("/dev/null", O_WRONLY, 0);
ConfError e;
if (conf_parse(&conf, (const char *)data, size, &e)) {
ensure(conf.nsections <= CONF_SECTION_MAX);
ensure(conf.nentries <= CONF_ENTRY_MAX);
[[maybe_unused]] bool dumped = conf_dump(&conf, sink);
ensure(dumped);
} else {
ensure(e.msg[0] != '\0');
}
return 0;
}