Add MockedEmptyHandlersServer fuzz target

This commit is contained in:
Alex Hultman
2020-01-12 18:22:54 +01:00
parent 02f1ceeba0
commit 42977d3570
2 changed files with 37 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#include "App.h"
#include "helpers.h"
/* This function pushes data to the uSockets mock */
extern "C" void us_loop_read_mocked_data(struct us_loop *loop, char *data, unsigned int size);
uWS::TemplatedApp<false> *app;
us_listen_socket_t *listenSocket;
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
app = new uWS::App();
struct PerSocketData {
int nothing;
};
app->ws<PerSocketData>("/*", {
/* Having no handlers here should not crash */
}).listen(9001, [](us_listen_socket_t *listenSocket) {
if (listenSocket) {
std::cout << "Listening on port " << 9001 << std::endl;
::listenSocket = listenSocket;
}
});
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
us_loop_read_mocked_data((struct us_loop *) uWS::Loop::get(), (char *) makePadded(data, size), size);
return 0;
}