-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Off-by-one write in ws_connect reported by valgrind (IDFGH-13644) (IDFGH-13651) #647
Comments
Thanks for reporting! and using The issue you're seeing stems from reading the WebSocket header, a quick fix would be to: diff --git a/components/tcp_transport/transport_ws.c b/components/tcp_transport/transport_ws.c
index 4aaa1845ed9..80a7c71c41d 100644
--- a/components/tcp_transport/transport_ws.c
+++ b/components/tcp_transport/transport_ws.c
@@ -285,13 +285,14 @@ 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;
} PS: We received a similar report in espressif/esp-idf#14473 |
Thank you @david-cermak I will close mine as a duplicate :) |
Should I submit a PR with the change above ^ |
Thanks for offering! However, let's hold off for now. I'd like to give the original author of the issue, who pinpointed the root cause, the first opportunity to submit a PR. |
Answers checklist.
IDF version.
master
Espressif SoC revision.
None/Linux build
Operating System used.
Linux
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
Development Kit.
linux
Power Supply used.
USB
What is the expected behavior?
Not to crash
What is the actual behavior?
This results in memory corruption/crashing
Steps to reproduce.
Run https://github.com/espressif/esp-protocols/tree/master/components/esp_websocket_client/examples/linux and use valgrind
Debug Logs.
More Information.
N/A
The text was updated successfully, but these errors were encountered: