You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both copy an HTTP response body of arbitrary length (from whatever peer/server was called) into a caller-supplied fixed-size `char *response` buffer with no length check - the same overflow shape as the `setCredentials()`/`onYoYoRequestPOST()` bugs fixed in #56/#57, just on the outgoing request path (a device calling another peer) rather than the incoming request path. Any caller passing a fixed-size stack/heap buffer as `response` is exposed to a heap/stack overflow if the remote peer's response is longer than expected.
Change the signature to take a `String&` instead of `char *`, avoiding the fixed-buffer assumption entirely (there's already a `GET(..., JsonDocument&)` overload that avoids this problem the same way).
Where
Two sites in `src/YoYoWiFiManager.cpp`, both flagged in source with `//#TODO: test length?`:
`POST(const char *server, const char *path, const char *payload, char *contentType, char *response)`:
```cpp
if(response && httpResponseCode > 0) {
//#TODO: test length?
strcpy(response, http.getString().c_str());
}
```
`GET(const char *server, const char *path, char *response)`:
```cpp
if (httpResponseCode > 0) {
//#TODO: test length?
strcpy(response, http.getString().c_str());
}
```
Problem
Both copy an HTTP response body of arbitrary length (from whatever peer/server was called) into a caller-supplied fixed-size `char *response` buffer with no length check - the same overflow shape as the `setCredentials()`/`onYoYoRequestPOST()` bugs fixed in #56/#57, just on the outgoing request path (a device calling another peer) rather than the incoming request path. Any caller passing a fixed-size stack/heap buffer as `response` is exposed to a heap/stack overflow if the remote peer's response is longer than expected.
Suggested fix
Either: