libreoffice-online/fuzzer/Admin.cpp
Miklos Vajna a4e0a00bfe Add an initial libfuzzer based fuzzer for the admin console
Run the actual fuzzer like this:

./admin_fuzzer -max_len=16384 fuzzer/admin-data/

Change-Id: I5891df8033ff1837afce86775ee62447587f2f20
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91504
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-04-02 12:11:24 +02:00

22 lines
587 B
C++

#include <iostream>
#include "Admin.hpp"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
Admin& admin = Admin::instance();
auto handler = std::make_shared<AdminSocketHandler>(&admin);
std::string input(reinterpret_cast<const char*>(data), size);
std::stringstream ss(input);
std::string line;
while (std::getline(ss, line, '\n'))
{
std::vector<char> lineVector(line.data(), line.data() + line.size());
handler->handleMessage(lineVector);
}
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */