From a52a8e0c9f66438b5cd63bda4df4bb219ae40ca4 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Tue, 12 Feb 2019 16:34:23 -0800 Subject: [PATCH] Fixed behavior so WebSoketServer does not mask data, when talking to clients, to fix interop issue with Chrome --- microscript/ILibDuktape_HttpStream.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/microscript/ILibDuktape_HttpStream.c b/microscript/ILibDuktape_HttpStream.c index 50f6df8..f654785 100644 --- a/microscript/ILibDuktape_HttpStream.c +++ b/microscript/ILibDuktape_HttpStream.c @@ -1412,6 +1412,7 @@ duk_ret_t ILibDuktape_HttpStream_http_server_upgradeWebsocket(duk_context *ctx) duk_get_prop_string(ctx, -1, "webSocketStream"); // [http][constructor] duk_push_lstring(ctx, keyResult, keyResultLen); // [http][constructor][key] duk_new(ctx, 1); // [http][wss] + ((ILibDuktape_WebSocket_State*)Duktape_GetBufferProperty(ctx, -1, ILibDuktape_WebSocket_StatePtr))->noMasking = 1; // Server cannot mask WebSockets when sending data duk_push_this(ctx); // [http][wss][socket] duk_get_prop_string(ctx, -1, "pipe"); // [http][wss][socket][pipe] @@ -3490,7 +3491,7 @@ ILibTransport_DoneState ILibDuktape_httpStream_webSocket_WriteWebSocketPacket(IL if (flags & WEBSOCKET_MASK) { // We have to copy memory anyways to mask, so we might as well copy the extra few bytes and make a single buffer - char *dataFrame = ILibMemory_AllocateA(headerLen + bufferLen); + char *dataFrame = ILibMemory_AllocateA(headerLen + 4 + bufferLen); char *maskKey = (dataFrame + headerLen); memcpy_s(dataFrame, headerLen, header, headerLen);