OLD | NEW |
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/quic_session.h" | 5 #include "net/quic/quic_session.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "net/quic/crypto/proof_verifier.h" | 10 #include "net/quic/crypto/proof_verifier.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 locally_closed_streams_highest_offset_.size()) > 0; | 232 locally_closed_streams_highest_offset_.size()) > 0; |
233 } | 233 } |
234 | 234 |
235 void QuicSession::ProcessUdpPacket(const IPEndPoint& self_address, | 235 void QuicSession::ProcessUdpPacket(const IPEndPoint& self_address, |
236 const IPEndPoint& peer_address, | 236 const IPEndPoint& peer_address, |
237 const QuicReceivedPacket& packet) { | 237 const QuicReceivedPacket& packet) { |
238 connection_->ProcessUdpPacket(self_address, peer_address, packet); | 238 connection_->ProcessUdpPacket(self_address, peer_address, packet); |
239 } | 239 } |
240 | 240 |
241 QuicConsumedData QuicSession::WritevData( | 241 QuicConsumedData QuicSession::WritevData( |
| 242 ReliableQuicStream* stream, |
242 QuicStreamId id, | 243 QuicStreamId id, |
243 QuicIOVector iov, | 244 QuicIOVector iov, |
244 QuicStreamOffset offset, | 245 QuicStreamOffset offset, |
245 bool fin, | 246 bool fin, |
246 QuicAckListenerInterface* ack_notifier_delegate) { | 247 QuicAckListenerInterface* ack_notifier_delegate) { |
| 248 // This check is an attempt to deal with potential memory corruption |
| 249 // in which |id| ends up set to 1 (the crypto stream id). If this happen |
| 250 // it might end up resulting in unencrypted stream data being sent. |
| 251 // While this is impossible to avoid given sufficient corruption, this |
| 252 // seems like a reasonable mitigation. |
| 253 if (id == kCryptoStreamId && stream != GetCryptoStream()) { |
| 254 QUIC_BUG << "Stream id mismatch"; |
| 255 connection_->CloseConnection( |
| 256 QUIC_INTERNAL_ERROR, |
| 257 "Non-crypto stream attempted to write data as crypto stream.", |
| 258 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 259 return QuicConsumedData(0, false); |
| 260 } |
247 if (!IsEncryptionEstablished() && id != kCryptoStreamId) { | 261 if (!IsEncryptionEstablished() && id != kCryptoStreamId) { |
248 // Do not let streams write without encryption. The calling stream will end | 262 // Do not let streams write without encryption. The calling stream will end |
249 // up write blocked until OnCanWrite is next called. | 263 // up write blocked until OnCanWrite is next called. |
250 return QuicConsumedData(0, false); | 264 return QuicConsumedData(0, false); |
251 } | 265 } |
252 QuicConsumedData data = | 266 QuicConsumedData data = |
253 connection_->SendStreamData(id, iov, offset, fin, ack_notifier_delegate); | 267 connection_->SendStreamData(id, iov, offset, fin, ack_notifier_delegate); |
254 write_blocked_streams_.UpdateBytesForStream(id, data.bytes_consumed); | 268 write_blocked_streams_.UpdateBytesForStream(id, data.bytes_consumed); |
255 return data; | 269 return data; |
256 } | 270 } |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 | 820 |
807 size_t QuicSession::MaxAvailableStreams() const { | 821 size_t QuicSession::MaxAvailableStreams() const { |
808 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; | 822 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; |
809 } | 823 } |
810 | 824 |
811 bool QuicSession::IsIncomingStream(QuicStreamId id) const { | 825 bool QuicSession::IsIncomingStream(QuicStreamId id) const { |
812 return id % 2 != next_outgoing_stream_id_ % 2; | 826 return id % 2 != next_outgoing_stream_id_ % 2; |
813 } | 827 } |
814 | 828 |
815 } // namespace net | 829 } // namespace net |
OLD | NEW |