Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: net/quic/quic_connection_test.cc

Issue 1987523003: Consider receiving crypto frames on non crypto stream as memory corruption. Protected by FLAG_quic_… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@122080193
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_flags.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <errno.h> 7 #include <errno.h>
8 #include <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 #include <utility> 10 #include <utility>
(...skipping 4945 matching lines...) Expand 10 before | Expand all | Expand 10 after
4956 // Verifies that multiple calls to CloseConnection do not 4956 // Verifies that multiple calls to CloseConnection do not
4957 // result in multiple attempts to close the connection - it will be marked as 4957 // result in multiple attempts to close the connection - it will be marked as
4958 // disconnected after the first call. 4958 // disconnected after the first call.
4959 EXPECT_CALL(visitor_, OnConnectionClosed(_, _, _)).Times(1); 4959 EXPECT_CALL(visitor_, OnConnectionClosed(_, _, _)).Times(1);
4960 connection_.CloseConnection(QUIC_NO_ERROR, "no reason", 4960 connection_.CloseConnection(QUIC_NO_ERROR, "no reason",
4961 ConnectionCloseBehavior::SILENT_CLOSE); 4961 ConnectionCloseBehavior::SILENT_CLOSE);
4962 connection_.CloseConnection(QUIC_NO_ERROR, "no reason", 4962 connection_.CloseConnection(QUIC_NO_ERROR, "no reason",
4963 ConnectionCloseBehavior::SILENT_CLOSE); 4963 ConnectionCloseBehavior::SILENT_CLOSE);
4964 } 4964 }
4965 4965
4966 TEST_P(QuicConnectionTest, ServerReceivesChloOnNonCryptoStream) {
4967 FLAGS_quic_detect_memory_corrpution = true;
4968 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4969
4970 set_perspective(Perspective::IS_SERVER);
4971 QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false);
4972
4973 CryptoHandshakeMessage message;
4974 CryptoFramer framer;
4975 message.set_tag(kCHLO);
4976 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
4977 frame1_.stream_id = 10;
4978 frame1_.data_buffer = data->data();
4979 frame1_.data_length = data->length();
4980
4981 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _,
4982 ConnectionCloseSource::FROM_SELF));
4983 ProcessFramePacket(QuicFrame(&frame1_));
4984 }
4985
4986 TEST_P(QuicConnectionTest, ClientReceivesRejOnNonCryptoStream) {
4987 FLAGS_quic_detect_memory_corrpution = true;
4988 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4989
4990 CryptoHandshakeMessage message;
4991 CryptoFramer framer;
4992 message.set_tag(kREJ);
4993 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
4994 frame1_.stream_id = 10;
4995 frame1_.data_buffer = data->data();
4996 frame1_.data_length = data->length();
4997
4998 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _,
4999 ConnectionCloseSource::FROM_SELF));
5000 ProcessFramePacket(QuicFrame(&frame1_));
5001 }
5002
4966 } // namespace 5003 } // namespace
4967 } // namespace test 5004 } // namespace test
4968 } // namespace net 5005 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698