Skip to content

Commit 41c845e

Browse files
committed
Restore _pinfo.masked to a boolean state (0 or 1) to keep backward compatibility.
1 parent 8664861 commit 41c845e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/AsyncWebSocket.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,17 +541,20 @@ void AsyncWebSocketClient::_onData(void *pbuf, size_t plen) {
541541

542542
if (_pinfo.masked > 0 && _pinfo.masked < 5) {
543543
// Handle fragmented mask data - Safari may split the 4-byte mask across multiple packets
544-
while (_pinfo.masked < 5) {
544+
int mask_bytes_read = _pinfo.masked - 1;
545+
while (mask_bytes_read < 4) {
545546
if (plen == 0) {
546547
// wait for more data
548+
_pinfo.masked = mask_bytes_read + 1;
547549
_pstate = 1;
548550
return;
549551
}
550-
_pinfo.mask[_pinfo.masked - 1] = data[0];
552+
_pinfo.mask[mask_bytes_read] = data[0];
551553
data += 1;
552554
plen -= 1;
553-
_pinfo.masked++;
555+
mask_bytes_read++;
554556
}
557+
_pinfo.masked = 1; // restore boolean semantics: mask fully read
555558
}
556559

557560
const size_t datalen = std::min((size_t)(_pinfo.len - _pinfo.index), plen);

0 commit comments

Comments
 (0)