diff --git a/components/tcp_transport/transport_ws.c b/components/tcp_transport/transport_ws.c index f7434aa02fb..b7db2efc08a 100644 --- a/components/tcp_transport/transport_ws.c +++ b/components/tcp_transport/transport_ws.c @@ -291,7 +291,7 @@ static int ws_connect(esp_transport_handle_t t, const char *host, int port, int } header_len += len; ws->buffer_len = header_len; - ws->buffer[header_len] = '\0'; // We will mark the end of the header to ensure that strstr operations for parsing the headers don't fail. + ws->buffer[header_len - 1] = '\0'; // We will mark the end of the header to ensure that strstr operations for parsing the headers don't fail. ESP_LOGD(TAG, "Read header chunk %d, current header size: %d", len, header_len); } while (NULL == strstr(ws->buffer, delimiter) && header_len < WS_BUFFER_SIZE);