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_framer.h" | 5 #include "net/quic/quic_framer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 QuicPacketNumber packet_number, | 1684 QuicPacketNumber packet_number, |
1685 const QuicPacket& packet, | 1685 const QuicPacket& packet, |
1686 char* buffer, | 1686 char* buffer, |
1687 size_t buffer_len) { | 1687 size_t buffer_len) { |
1688 DCHECK(encrypter_[level].get() != nullptr); | 1688 DCHECK(encrypter_[level].get() != nullptr); |
1689 | 1689 |
1690 StringPiece associated_data = packet.AssociatedData(); | 1690 StringPiece associated_data = packet.AssociatedData(); |
1691 // Copy in the header, because the encrypter only populates the encrypted | 1691 // Copy in the header, because the encrypter only populates the encrypted |
1692 // plaintext content. | 1692 // plaintext content. |
1693 const size_t ad_len = associated_data.length(); | 1693 const size_t ad_len = associated_data.length(); |
1694 memcpy(buffer, associated_data.data(), ad_len); | 1694 memmove(buffer, associated_data.data(), ad_len); |
1695 // Encrypt the plaintext into the buffer. | 1695 // Encrypt the plaintext into the buffer. |
1696 size_t output_length = 0; | 1696 size_t output_length = 0; |
1697 if (!encrypter_[level]->EncryptPacket(packet_number, associated_data, | 1697 if (!encrypter_[level]->EncryptPacket(packet_number, associated_data, |
1698 packet.Plaintext(), buffer + ad_len, | 1698 packet.Plaintext(), buffer + ad_len, |
1699 &output_length, buffer_len - ad_len)) { | 1699 &output_length, buffer_len - ad_len)) { |
1700 RaiseError(QUIC_ENCRYPTION_FAILURE); | 1700 RaiseError(QUIC_ENCRYPTION_FAILURE); |
1701 return 0; | 1701 return 0; |
1702 } | 1702 } |
1703 | 1703 |
1704 return ad_len + output_length; | 1704 return ad_len + output_length; |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2260 | 2260 |
2261 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2261 bool QuicFramer::RaiseError(QuicErrorCode error) { |
2262 DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error) | 2262 DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error) |
2263 << " detail: " << detailed_error_; | 2263 << " detail: " << detailed_error_; |
2264 set_error(error); | 2264 set_error(error); |
2265 visitor_->OnError(this); | 2265 visitor_->OnError(this); |
2266 return false; | 2266 return false; |
2267 } | 2267 } |
2268 | 2268 |
2269 } // namespace net | 2269 } // namespace net |
OLD | NEW |