aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2021-11-10 16:26:18 +0000
committerAndy Green <andy@warmcat.com>2021-11-22 15:42:14 +0000
commitd42a7900d6e1c1ed533ca4206d4f248b96d48a11 (patch)
treeb26faff10bd7ec0c2b7c97a0762663b67682eae8
parentc1828713582d5c9d50c9fbde151c577e9583e413 (diff)
downloadlibwebsockets-d42a7900d6e1c1ed533ca4206d4f248b96d48a11.tar.gz
ws: client: fail server link if masked
-rw-r--r--lib/roles/ws/client-parser-ws.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/roles/ws/client-parser-ws.c b/lib/roles/ws/client-parser-ws.c
index 09e681f9..f569532e 100644
--- a/lib/roles/ws/client-parser-ws.c
+++ b/lib/roles/ws/client-parser-ws.c
@@ -177,6 +177,8 @@ int lws_ws_client_rx_sm(struct lws *wsi, unsigned char c)
case LWS_RXPS_04_FRAME_HDR_LEN:
wsi->ws->this_frame_masked = !!(c & 0x80);
+ if (wsi->ws->this_frame_masked)
+ goto server_cannot_mask;
switch (c & 0x7f) {
case 126:
@@ -676,6 +678,16 @@ illegal_ctl_length:
/* kill the connection */
return -1;
+
+server_cannot_mask:
+ lws_close_reason(wsi,
+ LWS_CLOSE_STATUS_PROTOCOL_ERR,
+ (uint8_t *)"srv mask", 8);
+
+ lwsl_wsi_warn(wsi, "Server must not mask");
+
+ /* kill the connection */
+ return -1;
}