From 56a54afae95708d771f9b94d3c5244a62ed67347 Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Date: Tue, 27 Sep 2022 11:00:37 +0200 Subject: [PATCH] [tcp_transport] Bugfix: Remove unecessary mask_key check - In the processing of WS payload the check for a valid mask_key was made by checking for a valid address. The address is always valid and the test is meaningless. - Mask key is initialized in the process of header reading and set to 0 in case of mask not set. --- components/tcp_transport/transport_ws.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/components/tcp_transport/transport_ws.c b/components/tcp_transport/transport_ws.c index c0d91a1579..daea861390 100644 --- a/components/tcp_transport/transport_ws.c +++ b/components/tcp_transport/transport_ws.c @@ -363,10 +363,8 @@ static int ws_read_payload(esp_transport_handle_t t, char *buffer, int len, int } ws->frame_state.bytes_remaining -= rlen; - if (ws->frame_state.mask_key) { - for (int i = 0; i < bytes_to_read; i++) { - buffer[i] = (buffer[i] ^ ws->frame_state.mask_key[i % 4]); - } + for (int i = 0; i < bytes_to_read; i++) { + buffer[i] = (buffer[i] ^ ws->frame_state.mask_key[i % 4]); } return rlen; }