Skip to content

websocket, fix curl_ws_recv() - #12945

Closed
icing wants to merge 3 commits into
curl:masterfrom
icing:ws-recv-offset-fix
Closed

icing wants to merge 3 commits into
curl:masterfrom
icing:ws-recv-offset-fix

Conversation

@icing

@icing icing commented Feb 15, 2024

Copy link
Copy Markdown
Contributor
  • when data arrived in several chunks, the collection into the passed buffer always started at offset 0, overwriting the data already there.

@icing
icing marked this pull request as ready for review February 15, 2024 15:41
@calvin2021y

Copy link
Copy Markdown

maybe a unit tests can prevent this kind error.

@icing

icing commented Feb 16, 2024

Copy link
Copy Markdown
Contributor Author

maybe a unit tests can prevent this kind error.

It was triggered in pytest test_20_06, but it depended on how data arrived from the server. Any suggestion for a reliable test appreciated.

@calvin2021y

Copy link
Copy Markdown

maybe use netcat and pv to limit the send speed of a exists tcp stream

nc -l -p 8888 | pv -L 512  | nc example.com 80

in this example pv limit the stream speed at 512 byte per second.

@jay

jay commented Feb 16, 2024

Copy link
Copy Markdown
Member

It was triggered in pytest test_20_06, but it depended on how data arrived from the server.

Would CURL_DBG_SOCK_RMAX work for that

- when data arrived in several chunks, the collection into
  the passed buffer always started at offset 0, overwriting
  the data already there.
- debug environment var CURL_WS_CHUNK_SIZE can be used to
  influence the buffer chunk size used for en-/decoding.
@icing
icing force-pushed the ws-recv-offset-fix branch from 2d99720 to 5f1abf4 Compare February 20, 2024 09:14
@github-actions github-actions Bot added the tests label Feb 20, 2024
@icing

icing commented Feb 20, 2024

Copy link
Copy Markdown
Contributor Author

It was triggered in pytest test_20_06, but it depended on how data arrived from the server.

Would CURL_DBG_SOCK_RMAX work for that

Added a new debug environment var CURL_WS_CHUNK_SIZE to influence the buffer dimensions used in en-/decoding for websockets. This exposes the bug in test_20-07 and verifies the fix.

@bagder bagder closed this in f0c446a Feb 20, 2024
@bagder

bagder commented Feb 20, 2024

Copy link
Copy Markdown
Member

Thanks!

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

Development

Successfully merging this pull request may close these issues.

4 participants