c65d8e7c7f
fuzzers build was failing with: In file included from fuzzer/Admin.cpp:3: In file included from ./wsd/Admin.hpp:12: In file included from ./wsd/AdminModel.hpp:20: In file included from ./net/WebSocketHandler.hpp:18: ./net/HttpRequest.hpp:667:31: error: expected ')' _header.add("Server", HTTP_SERVER_STRING); ^ ./common/Common.hpp:62:51: note: expanded from macro 'HTTP_SERVER_STRING' #define HTTP_SERVER_STRING "LOOLWSD HTTP Server " LOOLWSD_VERSION ^ ./net/HttpRequest.hpp:667:20: note: to match this '(' _header.add("Server", HTTP_SERVER_STRING); ^ Signed-off-by: Miklos Vajna <vmiklos@collabora.com> Change-Id: Ibc3905e3e62e0eb9788b750971916ff4a4937f12
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
#include <iostream>
|
|
|
|
#include "config.h"
|
|
|
|
#include "ClientSession.hpp"
|
|
|
|
bool DoInitialization()
|
|
{
|
|
LOOLWSD::ChildRoot = "/fuzz/child-root";
|
|
return true;
|
|
}
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
|
{
|
|
static bool initialized = DoInitialization();
|
|
(void)initialized;
|
|
|
|
std::string uri;
|
|
Poco::URI uriPublic;
|
|
std::string docKey = "/fuzz/fuzz.odt";
|
|
auto docBroker = std::make_shared<DocumentBroker>(DocumentBroker::ChildType::Interactive, uri,
|
|
uriPublic, docKey);
|
|
|
|
std::shared_ptr<ProtocolHandlerInterface> ws;
|
|
std::string id;
|
|
bool isReadOnly = false;
|
|
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, uri,
|
|
Poco::Net::HTTPMessage::HTTP_1_1);
|
|
request.setHost("localhost:9980");
|
|
const RequestDetails requestDetails(request, "");
|
|
auto session
|
|
= std::make_shared<ClientSession>(ws, id, docBroker, uriPublic, isReadOnly, requestDetails);
|
|
|
|
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());
|
|
session->handleMessage(lineVector);
|
|
}
|
|
|
|
// Make sure SocketPoll::_newCallbacks does not grow forever, leading to OOM.
|
|
Admin::instance().poll(std::chrono::microseconds(0));
|
|
|
|
// Make sure the anon map does not grow forever, leading to OOM.
|
|
Util::clearAnonymized();
|
|
return 0;
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|