Skip to content
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

ws->header gets clobbered by writes #1

Open
snej opened this issue Jan 11, 2017 · 0 comments
Open

ws->header gets clobbered by writes #1

snej opened this issue Jan 11, 2017 · 0 comments

Comments

@snej
Copy link

snej commented Jan 11, 2017

The field ws->header is documented as "Header for received websocket frame", but it's also modified while sending a frame (both ws_msg_frame_data_begin and _ws_send_frame_raw replace its contents.)

I don't understand the flow of control of the whole library, but it looks as though, if read and write calls are interleaved, the read side will get confused because the write side has changed the header field. For example, _ws_read_websocket uses ws->header.payload_len to keep track of how many bytes still need to be read. If a partial frame is read, and then a frame is sent, then when the next part of the incoming frame is read, payload_len will be wrong (it will refer to the size of the outgoing frame.)

As far as I can tell, the way to fix this is to add a second ws_header_t field, and have all the sending functions use that one instead.

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

No branches or pull requests

1 participant