Skip to content

WebSocketClient: check extended length/mask bytes are available #203

Open
pennam wants to merge 3 commits into
arduino-libraries:masterfrom
pennam:websocket-parse-fix
Open

WebSocketClient: check extended length/mask bytes are available #203
pennam wants to merge 3 commits into
arduino-libraries:masterfrom
pennam:websocket-parse-fix

Conversation

@pennam

@pennam pennam commented Jul 13, 2026

Copy link
Copy Markdown

Only 2 header bytes were guaranteed before reading the extended length and
mask, so a partial header made read() return -1 and corrupt iRxSize. Bail
out until all header bytes have arrived.

pennam added 3 commits July 13, 2026 15:53
Multiple read() calls in one expression have unspecified evaluation order
in C++, so the length bytes could be combined wrong. Read each byte into
its own variable before combining them.
Default iRxSize to the inline length and only override it for the 126/127
extended-length cases. No behavioural change.
Only 2 header bytes were guaranteed before reading the extended length and
mask, so a partial header made read() return -1 and corrupt iRxSize. Bail
out until all header bytes have arrived.
@pennam pennam requested review from pillo79 and rhpco July 13, 2026 13:56
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Jul 13, 2026

@pillo79 pillo79 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions

Copy link
Copy Markdown

Memory usage change @ d0a7577

Board flash % RAM for global variables %
arduino:samd:mkr1000 🔺 0 - +40 0.0 - +0.02 0 - 0 0.0 - 0.0
Click for full report table
Board examples/BasicAuthGet
flash
% examples/BasicAuthGet
RAM for global variables
% examples/CustomHeader
flash
% examples/CustomHeader
RAM for global variables
% examples/DweetGet
flash
% examples/DweetGet
RAM for global variables
% examples/DweetPost
flash
% examples/DweetPost
RAM for global variables
% examples/HueBlink
flash
% examples/HueBlink
RAM for global variables
% examples/ParseURL
flash
% examples/ParseURL
RAM for global variables
% examples/PostWithHeaders
flash
% examples/PostWithHeaders
RAM for global variables
% examples/SimpleDelete
flash
% examples/SimpleDelete
RAM for global variables
% examples/SimpleGet
flash
% examples/SimpleGet
RAM for global variables
% examples/SimpleHttpExample
flash
% examples/SimpleHttpExample
RAM for global variables
% examples/SimplePost
flash
% examples/SimplePost
RAM for global variables
% examples/SimplePut
flash
% examples/SimplePut
RAM for global variables
% examples/SimpleWebSocket
flash
% examples/SimpleWebSocket
RAM for global variables
%
arduino:samd:mkr1000 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 40 0.02 0 0.0
Click for full report CSV
Board,examples/BasicAuthGet<br>flash,%,examples/BasicAuthGet<br>RAM for global variables,%,examples/CustomHeader<br>flash,%,examples/CustomHeader<br>RAM for global variables,%,examples/DweetGet<br>flash,%,examples/DweetGet<br>RAM for global variables,%,examples/DweetPost<br>flash,%,examples/DweetPost<br>RAM for global variables,%,examples/HueBlink<br>flash,%,examples/HueBlink<br>RAM for global variables,%,examples/ParseURL<br>flash,%,examples/ParseURL<br>RAM for global variables,%,examples/PostWithHeaders<br>flash,%,examples/PostWithHeaders<br>RAM for global variables,%,examples/SimpleDelete<br>flash,%,examples/SimpleDelete<br>RAM for global variables,%,examples/SimpleGet<br>flash,%,examples/SimpleGet<br>RAM for global variables,%,examples/SimpleHttpExample<br>flash,%,examples/SimpleHttpExample<br>RAM for global variables,%,examples/SimplePost<br>flash,%,examples/SimplePost<br>RAM for global variables,%,examples/SimplePut<br>flash,%,examples/SimplePut<br>RAM for global variables,%,examples/SimpleWebSocket<br>flash,%,examples/SimpleWebSocket<br>RAM for global variables,%
arduino:samd:mkr1000,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,40,0.02,0,0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants