Skip to content

Commit 4a55ee9

Browse files
committed
AsyncWebSocket: Fix packet buffer smash
In a misguided attempt to work around badly written clients, AsyncWebSocketClient::_onData was trying to restore the value of the byte one past the end of the packet buffer. Unfortunately, that value might have been *correctly* changed by the callback, such as when it's storing heap metadata. This seemed to be causing of websocket-related crashes in WLED on ESP8266.
1 parent 551395f commit 4a55ee9

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

src/AsyncWebSocket.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,6 @@ void AsyncWebSocketClient::_onData(void *pbuf, size_t plen){
721721
}
722722

723723
const size_t datalen = std::min((size_t)(_pinfo.len - _pinfo.index), plen);
724-
const auto datalast = data[datalen];
725724

726725
if(_pinfo.masked){
727726
for(size_t i=0;i<datalen;i++)
@@ -772,10 +771,6 @@ void AsyncWebSocketClient::_onData(void *pbuf, size_t plen){
772771
break;
773772
}
774773

775-
// restore byte as _handleEvent may have added a null terminator i.e., data[len] = 0;
776-
if (datalen > 0)
777-
data[datalen] = datalast;
778-
779774
data += datalen;
780775
plen -= datalen;
781776
}

0 commit comments

Comments
 (0)