Chromium Code Reviews| Index: net/quic/quic_packet_creator.cc |
| diff --git a/net/quic/quic_packet_creator.cc b/net/quic/quic_packet_creator.cc |
| index 686fed285aa346abec8bdbf36b73736f98e9583f..fdc03d55c8233a84d53133454e5a3f16677dd7f3 100644 |
| --- a/net/quic/quic_packet_creator.cc |
| +++ b/net/quic/quic_packet_creator.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/logging.h" |
| #include "base/macros.h" |
| +#include "net/quic/crypto/crypto_protocol.h" |
| #include "net/quic/crypto/quic_random.h" |
| #include "net/quic/quic_bug_tracker.h" |
| #include "net/quic/quic_data_writer.h" |
| @@ -165,6 +166,21 @@ bool QuicPacketCreator::ConsumeData(QuicStreamId id, |
| return false; |
| } |
| CreateStreamFrame(id, iov, iov_offset, offset, fin, frame); |
| + // Explicitly disallow multi-packet CHLOs. |
| + if (FLAGS_quic_disallow_multi_packet_chlo && id == kCryptoStreamId && |
| + frame->stream_frame->data_length >= sizeof(kCHLO) && |
| + strncmp(frame->stream_frame->data_buffer, |
| + reinterpret_cast<const char*>(&kCHLO), sizeof(kCHLO)) == 0) { |
| + DCHECK_EQ(static_cast<size_t>(0), iov_offset); |
|
Ryan Hamilton
2016/05/25 02:29:20
nit: instead of static cast, can you just do 0u?
|
| + if (frame->stream_frame->data_length < iov.iov->iov_len) { |
| + const string error_details = "Client hello won't fit in a single packet."; |
| + QUIC_BUG << error_details; |
| + delegate_->OnUnrecoverableError(QUIC_CRYPTO_CHLO_TOO_LARGE, error_details, |
| + ConnectionCloseSource::FROM_SELF); |
| + delete frame->stream_frame; |
| + return false; |
| + } |
| + } |
| if (!AddFrame(*frame, /*save_retransmittable_frames=*/true)) { |
| // Fails if we try to write unencrypted stream data. |
| delete frame->stream_frame; |