Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: net/websockets/websocket_channel.cc

Issue 177403002: net::WebSocketChannel should reject reserved bits (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix typo. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/websockets/websocket_channel_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/websockets/websocket_channel.h" 5 #include "net/websockets/websocket_channel.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" // for size_t 9 #include "base/basictypes.h" // for size_t
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 } 646 }
647 const WebSocketFrameHeader::OpCode opcode = frame->header.opcode; 647 const WebSocketFrameHeader::OpCode opcode = frame->header.opcode;
648 if (WebSocketFrameHeader::IsKnownControlOpCode(opcode) && 648 if (WebSocketFrameHeader::IsKnownControlOpCode(opcode) &&
649 !frame->header.final) { 649 !frame->header.final) {
650 return FailChannel( 650 return FailChannel(
651 base::StringPrintf("Received fragmented control frame: opcode = %d", 651 base::StringPrintf("Received fragmented control frame: opcode = %d",
652 opcode), 652 opcode),
653 kWebSocketErrorProtocolError, 653 kWebSocketErrorProtocolError,
654 "Control message with FIN bit unset received"); 654 "Control message with FIN bit unset received");
655 } 655 }
656 if (frame->header.reserved1 || frame->header.reserved2 ||
657 frame->header.reserved3) {
658 return FailChannel("Received a frame with an invalid reserved bit set.",
659 kWebSocketErrorProtocolError,
660 "Invalid reserved bit");
661 }
656 662
657 // Respond to the frame appropriately to its type. 663 // Respond to the frame appropriately to its type.
658 return HandleFrameByState( 664 return HandleFrameByState(
659 opcode, frame->header.final, frame->data, frame->header.payload_length); 665 opcode, frame->header.final, frame->data, frame->header.payload_length);
660 } 666 }
661 667
662 ChannelState WebSocketChannel::HandleFrameByState( 668 ChannelState WebSocketChannel::HandleFrameByState(
663 const WebSocketFrameHeader::OpCode opcode, 669 const WebSocketFrameHeader::OpCode opcode,
664 bool final, 670 bool final,
665 const scoped_refptr<IOBuffer>& data_buffer, 671 const scoped_refptr<IOBuffer>& data_buffer,
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 948
943 void WebSocketChannel::CloseTimeout() { 949 void WebSocketChannel::CloseTimeout() {
944 stream_->Close(); 950 stream_->Close();
945 DCHECK_NE(CLOSED, state_); 951 DCHECK_NE(CLOSED, state_);
946 state_ = CLOSED; 952 state_ = CLOSED;
947 AllowUnused(DoDropChannel(false, kWebSocketErrorAbnormalClosure, "")); 953 AllowUnused(DoDropChannel(false, kWebSocketErrorAbnormalClosure, ""));
948 // |this| has been deleted. 954 // |this| has been deleted.
949 } 955 }
950 956
951 } // namespace net 957 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/websockets/websocket_channel_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698