mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
fix(tcp_transport): Fix websocket header read to handle overflow
This commit is contained in:
parent
9dcd2990a7
commit
89ef743876
@ -293,7 +293,12 @@ static int ws_connect(esp_transport_handle_t t, const char *host, int port, int
|
||||
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.
|
||||
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);
|
||||
} while (NULL == strstr(ws->buffer, delimiter) && header_len < WS_BUFFER_SIZE - 1);
|
||||
|
||||
if (header_len >= WS_BUFFER_SIZE - 1) {
|
||||
ESP_LOGE(TAG, "Header size exceeded buffer size");
|
||||
return -1;
|
||||
}
|
||||
|
||||
char* delim_ptr = strstr(ws->buffer, delimiter);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user