Skip to content

aiohttp: ws: fix truncated read of payload #1038

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

mirko
Copy link

@mirko mirko commented Jul 31, 2025

aiohttp: fix partial read on websocket resulting in truncated payload

Attempting to read N bytes from a socket does not guarantee to actually
read N bytes, even if >= N bytes were written onto the peer socket.

This especially becomes an issues when attempting to read larger
messages at once, which then potentially can't be read all at once,
resulting in truncated payloads.

Fix that by reading as long / often until expected length was actually
received.

Attempting to read N bytes from a socket does not guarantee to actually
read N bytes, even if >= N bytes were written onto the peer socket.

This especially becomes an issues when attempting to read larger
messages at once, which then potentially can't be read all at once,
resulting in truncated payloads.

Fix that by reading as long / often until expected length was actually
received.
@dpgeorge
Copy link
Member

dpgeorge commented Aug 1, 2025

This should be fixed by #1034 (that was merged yesterday).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants