mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(transport_ws): fix handshake failure with small response buffer
This commit is contained in:
@@ -277,13 +277,14 @@ static int ws_connect(esp_transport_handle_t t, const char *host, int port, int
|
||||
}
|
||||
|
||||
if(ws->response_header) {
|
||||
int copy_len = header_len;
|
||||
if(ws->response_header_len - 1 < header_len) {
|
||||
ESP_LOGW(TAG, "Received header length exceedes the allocated buffer size (need=%d, allocated=%d), truncating to allocated size", header_len, ws->response_header_len);
|
||||
header_len = ws->response_header_len;
|
||||
copy_len = ws->response_header_len - 1;
|
||||
}
|
||||
// Copy response header to the static array
|
||||
strncpy(ws->response_header, ws->buffer, header_len);
|
||||
ws->response_header[ws->response_header_len - 1] = '\0';
|
||||
strncpy(ws->response_header, ws->buffer, copy_len);
|
||||
ws->response_header[copy_len] = '\0';
|
||||
}
|
||||
|
||||
char* delim_ptr = strstr(ws->buffer, delimiter);
|
||||
|
||||
Reference in New Issue
Block a user