Skip to content

websocket: Implement 64-bit frames, enable split frames. #17830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jepler
Copy link
Contributor

@jepler jepler commented Aug 4, 2025

Summary

This fixes several assertion errors that were found in fuzz testing, for unimplemented portions of the websocket spec. The assertions were either turned into Python exceptions, or the missing functionality was implemented.

Frames larger than 4GB are unsupported. Initial reception of such a frame will result in OSError(EIO) and subsequent operations on the same websocket will result in OSError(ECONNRESET), because framing has been lost.

Transmitting frames larger than 64kB is unsupported. Attempting to transmit such a frame will result in OSError(ENOBUFS). Subsequent operations on the websocket are possible.

Testing

I added tests for the new & updated functionality and endorsed the output because I think it's correct.

Trade-offs and Alternatives

This will increase code size somewhat. There are other alternatives that would have less of a code size impact (e.g., not even partially implementing the 64 bit size option) while still turning assertion failures into proper runtime errors. This might be a better choice, as I assume the current websocket implementation is actually useful talking to websocket servers in the wild.

This fixes several assertion errors that were found in fuzz
testing, for unimplemented portions of the spec. The assertions
were either turned into Python exceptions, or the missing
functionality was implemented.

Frames larger than 4GB are unsupported. Initial reception of
such a frame will result in OSError(EIO) and subsequent operations
on the same websocket will fail because framing has been lost.

Transmitting frames larger than 64kB is unsupported. Attempting
to transmit such a frame will result in OSError(ENOBUFS). Subsequent
operations on the websocket are possible.

Signed-off-by: Jeff Epler <jepler@gmail.com>
@jepler jepler force-pushed the websocket-improvements branch from f438f98 to e2428a8 Compare August 4, 2025 15:23
Copy link

github-actions bot commented Aug 4, 2025

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:   +80 +0.009% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:   +64 +0.007% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@jepler
Copy link
Contributor Author

jepler commented Aug 4, 2025

Locally, excluding any support for 64-bit frame payload sizes saves back 36 bytes on RPI_PICO_W.

@dpgeorge dpgeorge added the extmod Relates to extmod/ directory in source label Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extmod Relates to extmod/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy