Index: net/quic/quic_connection_test.cc |
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc |
index 937dc286a66676cedb4c7c9f6ede559a59b9f196..760ef02c90927d3e383a5ff488d0e2f8f6651027 100644 |
--- a/net/quic/quic_connection_test.cc |
+++ b/net/quic/quic_connection_test.cc |
@@ -1944,7 +1944,7 @@ TEST_P(QuicConnectionTest, SendingZeroBytes) { |
// Send a zero byte write with a fin using writev. |
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
QuicIOVector empty_iov(nullptr, 0, 0); |
- connection_.SendStreamData(1, empty_iov, 0, kFin, nullptr); |
+ connection_.SendStreamData(kHeadersStreamId, empty_iov, 0, kFin, nullptr); |
EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
EXPECT_FALSE(connection_.HasQueuedData()); |
@@ -1952,7 +1952,7 @@ TEST_P(QuicConnectionTest, SendingZeroBytes) { |
// Parse the last packet and ensure it's one stream frame from one stream. |
EXPECT_EQ(1u, writer_->frame_count()); |
EXPECT_EQ(1u, writer_->stream_frames().size()); |
- EXPECT_EQ(1u, writer_->stream_frames()[0]->stream_id); |
+ EXPECT_EQ(kHeadersStreamId, writer_->stream_frames()[0]->stream_id); |
EXPECT_TRUE(writer_->stream_frames()[0]->fin); |
} |
@@ -2897,7 +2897,7 @@ TEST_P(QuicConnectionTest, HandshakeTimeout) { |
EXPECT_TRUE(connection_.connected()); |
// Send and ack new data 3 seconds later to lengthen the idle timeout. |
- SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr); |
+ SendStreamDataToPeer(kHeadersStreamId, "GET /", 0, kFin, nullptr); |
clock_.AdvanceTime(QuicTime::Delta::FromSeconds(3)); |
QuicAckFrame frame = InitAckFrame(1); |
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
@@ -2935,7 +2935,7 @@ TEST_P(QuicConnectionTest, PingAfterSend) { |
// the ping alarm. |
clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
- SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr); |
+ SendStreamDataToPeer(kHeadersStreamId, "GET /", 0, kFin, nullptr); |
EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); |
EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)), |
connection_.GetPingAlarm()->deadline()); |
@@ -3584,7 +3584,7 @@ TEST_P(QuicConnectionTest, SendDelayedAckDecimation) { |
QuicConnectionPeer::SetAckMode(&connection_, QuicConnection::ACK_DECIMATION); |
const size_t kMinRttMs = 40; |
- RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); |
+ RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
QuicTime::Delta::Zero(), QuicTime::Zero()); |
// The ack time should be based on min_rtt/4, since it's less than the |
@@ -3637,7 +3637,7 @@ TEST_P(QuicConnectionTest, SendDelayedAckDecimationEighthRtt) { |
QuicConnectionPeer::SetAckDecimationDelay(&connection_, 0.125); |
const size_t kMinRttMs = 40; |
- RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); |
+ RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
QuicTime::Delta::Zero(), QuicTime::Zero()); |
// The ack time should be based on min_rtt/8, since it's less than the |
@@ -3690,7 +3690,7 @@ TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithReordering) { |
&connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING); |
const size_t kMinRttMs = 40; |
- RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); |
+ RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
QuicTime::Delta::Zero(), QuicTime::Zero()); |
// The ack time should be based on min_rtt/4, since it's less than the |
@@ -3751,7 +3751,7 @@ TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithLargeReordering) { |
&connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING); |
const size_t kMinRttMs = 40; |
- RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); |
+ RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
QuicTime::Delta::Zero(), QuicTime::Zero()); |
// The ack time should be based on min_rtt/4, since it's less than the |
@@ -3825,7 +3825,7 @@ TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithReorderingEighthRtt) { |
QuicConnectionPeer::SetAckDecimationDelay(&connection_, 0.125); |
const size_t kMinRttMs = 40; |
- RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); |
+ RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
QuicTime::Delta::Zero(), QuicTime::Zero()); |
// The ack time should be based on min_rtt/8, since it's less than the |
@@ -3888,7 +3888,7 @@ TEST_P(QuicConnectionTest, |
QuicConnectionPeer::SetAckDecimationDelay(&connection_, 0.125); |
const size_t kMinRttMs = 40; |
- RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); |
+ RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
QuicTime::Delta::Zero(), QuicTime::Zero()); |
// The ack time should be based on min_rtt/8, since it's less than the |
@@ -4963,6 +4963,43 @@ TEST_P(QuicConnectionTest, MultipleCallsToCloseConnection) { |
ConnectionCloseBehavior::SILENT_CLOSE); |
} |
+TEST_P(QuicConnectionTest, ServerReceivesChloOnNonCryptoStream) { |
+ FLAGS_quic_detect_memory_corrpution = true; |
+ EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
+ |
+ set_perspective(Perspective::IS_SERVER); |
+ QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); |
+ |
+ CryptoHandshakeMessage message; |
+ CryptoFramer framer; |
+ message.set_tag(kCHLO); |
+ std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); |
+ frame1_.stream_id = 10; |
+ frame1_.data_buffer = data->data(); |
+ frame1_.data_length = data->length(); |
+ |
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, |
+ ConnectionCloseSource::FROM_SELF)); |
+ ProcessFramePacket(QuicFrame(&frame1_)); |
+} |
+ |
+TEST_P(QuicConnectionTest, ClientReceivesRejOnNonCryptoStream) { |
+ FLAGS_quic_detect_memory_corrpution = true; |
+ EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
+ |
+ CryptoHandshakeMessage message; |
+ CryptoFramer framer; |
+ message.set_tag(kREJ); |
+ std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); |
+ frame1_.stream_id = 10; |
+ frame1_.data_buffer = data->data(); |
+ frame1_.data_length = data->length(); |
+ |
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, |
+ ConnectionCloseSource::FROM_SELF)); |
+ ProcessFramePacket(QuicFrame(&frame1_)); |
+} |
+ |
} // namespace |
} // namespace test |
} // namespace net |