SSL message parsing fix #223
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been running into a problem with recent versions of ws4py where messages received in quick succession over an SSL connection are not properly parsed.
I believe the problem originated in this commit 75b88bd which can result in the
WebSocket.processmethod being called with more thanreading_buffer_sizebytes which seems to violate an assumption of the stream/frame parser. In specific, theStream.receivercoroutine does not pass unused bytes from the previousFrameto the nextFramewhich causes a problem should a single call toWebSocket.processinclude data for multiple frames.The
WebSocket.oncemethod has undergone several revisions since this change was first introduced but I believe the original problem remains. My proposed fix restores the old behavior of limiting the size of the byte string passed toWebSocket.processwhile still consuming all data received by the socket.I have added a couple unit tests for this behavior. Of particular note is
WSWebSocketTest.test_messages_parsing_sslwhich fails for me with python 2, 3, and pypy before the proposed change.