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

Side by Side Diff: net/quic/reliable_quic_stream_test.cc

Issue 1975483003: Fixes use-after-free bug in QUIC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Removes use of QuicHeaderList from merge CL. Created 4 years, 7 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 | « net/quic/quic_spdy_stream.cc ('k') | net/quic/test_tools/quic_session_peer.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/quic/reliable_quic_stream.h" 5 #include "net/quic/reliable_quic_stream.h"
6 6
7 #include "net/quic/quic_connection.h" 7 #include "net/quic/quic_connection.h"
8 #include "net/quic/quic_flags.h" 8 #include "net/quic/quic_flags.h"
9 #include "net/quic/quic_utils.h" 9 #include "net/quic/quic_utils.h"
10 #include "net/quic/quic_write_blocked_list.h" 10 #include "net/quic/quic_write_blocked_list.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 "QnyXHeGeK2UINUzJ-D30AFcpqYgH9_1BvYSpi7fc7_ydBU8TaD8ZRxvtnzXqj0RfG" 98 "QnyXHeGeK2UINUzJ-D30AFcpqYgH9_1BvYSpi7fc7_ydBU8TaD8ZRxvtnzXqj0RfG"
99 "tuHghmv3aD-uzSYJ75XDdzKdizZ86IG6Fbn1XFhYZM-fbHhm3mVEXnyRW4ZuNOLFk" 99 "tuHghmv3aD-uzSYJ75XDdzKdizZ86IG6Fbn1XFhYZM-fbHhm3mVEXnyRW4ZuNOLFk"
100 "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn" 100 "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn"
101 "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr" 101 "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr"
102 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo "; 102 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo ";
103 } 103 }
104 104
105 void Initialize(bool stream_should_process_data) { 105 void Initialize(bool stream_should_process_data) {
106 connection_ = new StrictMock<MockConnection>( 106 connection_ = new StrictMock<MockConnection>(
107 &helper_, Perspective::IS_SERVER, supported_versions_); 107 &helper_, Perspective::IS_SERVER, supported_versions_);
108 session_.reset(new StrictMock<MockQuicSpdySession>(connection_)); 108 session_.reset(new StrictMock<MockQuicSession>(connection_));
109 109
110 // New streams rely on having the peer's flow control receive window 110 // New streams rely on having the peer's flow control receive window
111 // negotiated in the config. 111 // negotiated in the config.
112 QuicConfigPeer::SetReceivedInitialStreamFlowControlWindow( 112 QuicConfigPeer::SetReceivedInitialStreamFlowControlWindow(
113 session_->config(), initial_flow_control_window_bytes_); 113 session_->config(), initial_flow_control_window_bytes_);
114 114
115 stream_ = new TestStream(kTestStreamId, session_.get(), 115 stream_ = new TestStream(kTestStreamId, session_.get(),
116 stream_should_process_data); 116 stream_should_process_data);
117 // session_ now owns stream_. 117 // session_ now owns stream_.
118 session_->ActivateStream(stream_); 118 session_->ActivateStream(stream_);
(...skipping 23 matching lines...) Expand all
142 QuicStreamOffset /*offset*/, 142 QuicStreamOffset /*offset*/,
143 bool /*fin*/, 143 bool /*fin*/,
144 QuicAckListenerInterface* /*ack_notifier_delegate*/) { 144 QuicAckListenerInterface* /*ack_notifier_delegate*/) {
145 session_->CloseStream(id); 145 session_->CloseStream(id);
146 return QuicConsumedData(1, false); 146 return QuicConsumedData(1, false);
147 } 147 }
148 148
149 protected: 149 protected:
150 MockConnectionHelper helper_; 150 MockConnectionHelper helper_;
151 MockConnection* connection_; 151 MockConnection* connection_;
152 scoped_ptr<MockQuicSpdySession> session_; 152 scoped_ptr<MockQuicSession> session_;
153 TestStream* stream_; 153 TestStream* stream_;
154 SpdyHeaderBlock headers_; 154 SpdyHeaderBlock headers_;
155 QuicWriteBlockedList* write_blocked_list_; 155 QuicWriteBlockedList* write_blocked_list_;
156 uint32_t initial_flow_control_window_bytes_; 156 uint32_t initial_flow_control_window_bytes_;
157 QuicTime::Delta zero_; 157 QuicTime::Delta zero_;
158 QuicVersionVector supported_versions_; 158 QuicVersionVector supported_versions_;
159 const QuicStreamId kTestStreamId = 5u; 159 const QuicStreamId kTestStreamId = 5u;
160 }; 160 };
161 161
162 TEST_F(ReliableQuicStreamTest, WriteAllData) { 162 TEST_F(ReliableQuicStreamTest, WriteAllData) {
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); 636 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams());
637 } 637 }
638 638
639 TEST_F(ReliableQuicStreamTest, EarlyResponseFinHandling) { 639 TEST_F(ReliableQuicStreamTest, EarlyResponseFinHandling) {
640 // Verify that if the server completes the response before reading the end of 640 // Verify that if the server completes the response before reading the end of
641 // the request, the received FIN is recorded. 641 // the request, the received FIN is recorded.
642 642
643 Initialize(kShouldProcessData); 643 Initialize(kShouldProcessData);
644 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0); 644 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0);
645 EXPECT_CALL(*session_, WritevData(_, _, _, _, _)) 645 EXPECT_CALL(*session_, WritevData(_, _, _, _, _))
646 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData)); 646 .WillRepeatedly(Invoke(MockQuicSession::ConsumeAllData));
647 647
648 // Receive data for the request. 648 // Receive data for the request.
649 QuicStreamFrame frame1(stream_->id(), false, 0, StringPiece("Start")); 649 QuicStreamFrame frame1(stream_->id(), false, 0, StringPiece("Start"));
650 stream_->OnStreamFrame(frame1); 650 stream_->OnStreamFrame(frame1);
651 // When QuicSimpleServerStream sends the response, it calls 651 // When QuicSimpleServerStream sends the response, it calls
652 // ReliableQuicStream::CloseReadSide() first. 652 // ReliableQuicStream::CloseReadSide() first.
653 ReliableQuicStreamPeer::CloseReadSide(stream_); 653 ReliableQuicStreamPeer::CloseReadSide(stream_);
654 // Send data and FIN for the response. 654 // Send data and FIN for the response.
655 stream_->WriteOrBufferData(kData1, false, nullptr); 655 stream_->WriteOrBufferData(kData1, false, nullptr);
656 EXPECT_TRUE(ReliableQuicStreamPeer::read_side_closed(stream_)); 656 EXPECT_TRUE(ReliableQuicStreamPeer::read_side_closed(stream_));
657 // Receive remaining data and FIN for the request. 657 // Receive remaining data and FIN for the request.
658 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End")); 658 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End"));
659 stream_->OnStreamFrame(frame2); 659 stream_->OnStreamFrame(frame2);
660 EXPECT_TRUE(stream_->fin_received()); 660 EXPECT_TRUE(stream_->fin_received());
661 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); 661 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset());
662 } 662 }
663 663
664 } // namespace 664 } // namespace
665 } // namespace test 665 } // namespace test
666 } // namespace net 666 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_spdy_stream.cc ('k') | net/quic/test_tools/quic_session_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698