Fuzz WebSockets in chunks
This commit is contained in:
@@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
#define WIN32_EXPORT
|
#define WIN32_EXPORT
|
||||||
|
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
/* We test the websocket parser */
|
/* We test the websocket parser */
|
||||||
#include "../src/WebSocketProtocol.h"
|
#include "../src/WebSocketProtocol.h"
|
||||||
|
|
||||||
/* We use this to pad the fuzz */
|
|
||||||
char *padded = new char[1024 * 500];
|
|
||||||
|
|
||||||
struct Impl {
|
struct Impl {
|
||||||
static bool refusePayloadLength(uint64_t length, uWS::WebSocketState<true> *wState, void *s) {
|
static bool refusePayloadLength(uint64_t length, uWS::WebSocketState<true> *wState, void *s) {
|
||||||
|
|
||||||
@@ -47,12 +46,13 @@ struct Impl {
|
|||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
|
|
||||||
/* Pad the fuzz */
|
/* Create the parser state */
|
||||||
uWS::WebSocketState<true> state;
|
uWS::WebSocketState<true> state;
|
||||||
memcpy(padded + 32, data, size);
|
|
||||||
|
|
||||||
/* Parse it */
|
makeChunked(makePadded(data, size), size, [&state](const uint8_t *data, size_t size) {
|
||||||
uWS::WebSocketProtocol<true, Impl>::consume((char *)padded + 32, size, &state, nullptr);
|
/* Parse it */
|
||||||
|
uWS::WebSocketProtocol<true, Impl>::consume((char *) data, size, &state, nullptr);
|
||||||
|
});
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user