Skip to content

Commit

Permalink
Fix off-by-one/memory corruption in transport_ws
Browse files Browse the repository at this point in the history
Read doesn't take NULL terminator into account

Resolves #14473
  • Loading branch information
Sean-Der committed Sep 24, 2024
1 parent 46acfdc commit 7d39798
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion components/tcp_transport/transport_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static int ws_connect(esp_transport_handle_t t, const char *host, int port, int
}
int header_len = 0;
do {
if ((len = esp_transport_read(ws->parent, ws->buffer + header_len, WS_BUFFER_SIZE - header_len, timeout_ms)) <= 0) {
if ((len = esp_transport_read(ws->parent, ws->buffer + header_len, WS_BUFFER_SIZE - header_len - 1, timeout_ms)) <= 0) {
ESP_LOGE(TAG, "Error read response for Upgrade header %s", ws->buffer);
return -1;
}
Expand Down

0 comments on commit 7d39798

Please sign in to comment.