From 88eb7b7e3b7b15255241b87cc82bde7779af2424 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:49:20 +0000 Subject: [PATCH] fix(ws): ensure client parser handles control frames internally The client-side bulk data handling optimization incorrectly bypassed the internal state machine for control frames (PING, PONG, CLOSE) when they carried a payload. This caused these frames to be passed to the user callback as LWS_CALLBACK_CLIENT_RECEIVE data, preventing the library from handling them correctly (e.g., auto-replying to PING). This patch forces the parser to fallback to the byte-by-byte state machine (lws_ws_client_rx_sm) whenever a control frame is detected (opcode & 8), even if the parser is in the payload state. This ensures control frames are processed correctly by the library. --- lib/roles/ws/client-parser-ws.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/roles/ws/client-parser-ws.c b/lib/roles/ws/client-parser-ws.c index 03d21f77ac..c667d13974 100644 --- a/lib/roles/ws/client-parser-ws.c +++ b/lib/roles/ws/client-parser-ws.c @@ -111,7 +111,8 @@ lws_ws_client_rx_parser_block(struct lws *wsi, const uint8_t **buf, size_t *len) * We can process headers and control frames byte-by-byte * using the original state machine. */ - if (wsi->lws_rx_parse_state != LWS_RXPS_WS_FRAME_PAYLOAD) { + if (wsi->lws_rx_parse_state != LWS_RXPS_WS_FRAME_PAYLOAD || + (wsi->ws->opcode & 8)) { hpr = lws_ws_client_rx_sm(wsi, *(*buf)); if (hpr != LWS_HPI_RET_HANDLED) return hpr;