fix websocket: apply control frame length limit to ping and pong - #1308
Open
netliomax25-code wants to merge 2 commits into
Open
fix websocket: apply control frame length limit to ping and pong#1308netliomax25-code wants to merge 2 commits into
netliomax25-code wants to merge 2 commits into
Conversation
Member
|
LGTM |
|
Many thanks for the PR! @apolukhin is now importing your pull request into our internal upstream repository. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
is_data_frameinReadWSFrameImplclassifies the opcode withopcode & (kText | kBinary), so ping (0x9) and pong (0xA) both test non-zero and count as data frames. The RFC 6455 5.5 guard just below it, which rejects a control frame withpayload_len > 125, never fires for them, and a client can send a ping carrying up tomax-remote-payloadbytes.MakeControlFrameassigns the size into a 7-bit field whileSendFramewrites the payload in full, so a 200-byte ping is answered with8A 48followed by 200 bytes. The peer takes 72 of them as the pong and parses the remaining 128 as further frames.Added
protocol_test.cppcovering the oversized ping and pong, a 125-byte ping, and a ping interleaved with a fragmented text message. The three new negative cases fail on the current tree (kNone instead of kProtocolError) and pass with the change; the rest ofuserver-core-unittestis unaffected.