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_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 return true; | 684 return true; |
685 } | 685 } |
686 | 686 |
687 bool QuicConnection::OnStreamFrame(const QuicStreamFrame& frame) { | 687 bool QuicConnection::OnStreamFrame(const QuicStreamFrame& frame) { |
688 DCHECK(connected_); | 688 DCHECK(connected_); |
689 if (debug_visitor_ != nullptr) { | 689 if (debug_visitor_ != nullptr) { |
690 debug_visitor_->OnStreamFrame(frame); | 690 debug_visitor_->OnStreamFrame(frame); |
691 } | 691 } |
692 if (frame.stream_id != kCryptoStreamId && | 692 if (frame.stream_id != kCryptoStreamId && |
693 last_decrypted_packet_level_ == ENCRYPTION_NONE) { | 693 last_decrypted_packet_level_ == ENCRYPTION_NONE) { |
| 694 if (FLAGS_quic_detect_memory_corrpution && |
| 695 MaybeConsiderAsMemoryCorruption(frame)) { |
| 696 CloseConnection(QUIC_MAYBE_CORRUPTED_MEMORY, |
| 697 "Received crypto frame on non crypto stream.", |
| 698 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 699 return false; |
| 700 } |
| 701 |
694 QUIC_BUG << ENDPOINT | 702 QUIC_BUG << ENDPOINT |
695 << "Received an unencrypted data frame: closing connection" | 703 << "Received an unencrypted data frame: closing connection" |
696 << " packet_number:" << last_header_.packet_number | 704 << " packet_number:" << last_header_.packet_number |
697 << " stream_id:" << frame.stream_id | 705 << " stream_id:" << frame.stream_id |
698 << " received_packets:" << received_packet_manager_.ack_frame(); | 706 << " received_packets:" << received_packet_manager_.ack_frame(); |
699 CloseConnection(QUIC_UNENCRYPTED_STREAM_DATA, | 707 CloseConnection(QUIC_UNENCRYPTED_STREAM_DATA, |
700 "Unencrypted stream data seen.", | 708 "Unencrypted stream data seen.", |
701 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 709 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
702 return false; | 710 return false; |
703 } | 711 } |
(...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 return received_packet_manager_.ack_frame_updated(); | 2435 return received_packet_manager_.ack_frame_updated(); |
2428 } | 2436 } |
2429 | 2437 |
2430 StringPiece QuicConnection::GetCurrentPacket() { | 2438 StringPiece QuicConnection::GetCurrentPacket() { |
2431 if (current_packet_data_ == nullptr) { | 2439 if (current_packet_data_ == nullptr) { |
2432 return StringPiece(); | 2440 return StringPiece(); |
2433 } | 2441 } |
2434 return StringPiece(current_packet_data_, last_size_); | 2442 return StringPiece(current_packet_data_, last_size_); |
2435 } | 2443 } |
2436 | 2444 |
| 2445 bool QuicConnection::MaybeConsiderAsMemoryCorruption( |
| 2446 const QuicStreamFrame& frame) { |
| 2447 if (frame.stream_id == kCryptoStreamId || |
| 2448 last_decrypted_packet_level_ != ENCRYPTION_NONE) { |
| 2449 return false; |
| 2450 } |
| 2451 |
| 2452 if (perspective_ == Perspective::IS_SERVER && |
| 2453 frame.data_length >= sizeof(kCHLO) && |
| 2454 strncmp(frame.data_buffer, reinterpret_cast<const char*>(&kCHLO), |
| 2455 sizeof(kCHLO)) == 0) { |
| 2456 return true; |
| 2457 } |
| 2458 |
| 2459 if (perspective_ == Perspective::IS_CLIENT && |
| 2460 frame.data_length >= sizeof(kREJ) && |
| 2461 strncmp(frame.data_buffer, reinterpret_cast<const char*>(&kREJ), |
| 2462 sizeof(kREJ)) == 0) { |
| 2463 return true; |
| 2464 } |
| 2465 |
| 2466 return false; |
| 2467 } |
| 2468 |
2437 } // namespace net | 2469 } // namespace net |
OLD | NEW |