Fix oss-fuzz reported issues
This commit is contained in:
@@ -6,14 +6,16 @@
|
||||
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::TemplatedApp<false>(uWS::App().get("/*", [](auto *res, auto *req) {
|
||||
res->end("Hello world!");
|
||||
}).listen(9001, [](auto *token) {
|
||||
if (token) {
|
||||
}).listen(9001, [](us_listen_socket_t *listenSocket) {
|
||||
if (listenSocket) {
|
||||
std::cout << "Listening on port " << 9001 << std::endl;
|
||||
::listenSocket = listenSocket;
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -25,4 +27,4 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-3
@@ -9,11 +9,19 @@
|
||||
|
||||
/* We use this to pad the fuzz */
|
||||
static inline const uint8_t *makePadded(const uint8_t *data, size_t size) {
|
||||
static char *padded = new char[1024 * 500];
|
||||
static int paddedLength = 512 * 1024;
|
||||
static char *padded = new char[128 + paddedLength + 128];
|
||||
|
||||
memcpy(padded, data, size);
|
||||
/* Increase landing area if required */
|
||||
if (paddedLength < size) {
|
||||
delete [] padded;
|
||||
paddedLength = size;
|
||||
padded = new char [128 + paddedLength + 128];
|
||||
}
|
||||
|
||||
return (uint8_t *) padded;
|
||||
memcpy(padded + 128, data, size);
|
||||
|
||||
return (uint8_t *) padded + 128;
|
||||
}
|
||||
|
||||
/* Splits the fuzz data in one or many chunks */
|
||||
|
||||
Reference in New Issue
Block a user