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

Unified Diff: net/quic/quic_framer_test.cc

Issue 153993015: Use an alternative fix for OneShotVisitor of CryptoFramer that doesn't (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_framer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_framer_test.cc
diff --git a/net/quic/quic_framer_test.cc b/net/quic/quic_framer_test.cc
index 6adf405f803bccb41dfa3b703e63ba64a660a8c9..2c33780ab87fc7b5637b1d1d0ea51abbe00e989e 100644
--- a/net/quic/quic_framer_test.cc
+++ b/net/quic/quic_framer_test.cc
@@ -94,21 +94,22 @@ size_t GetFecGroupOffset(bool include_version,
kPrivateFlagsSize;
}
+// Index into the message tag of the public reset packet.
+// Public resets always have full guids.
+const size_t kPublicResetPacketMessageTagOffset =
+ kGuidOffset + PACKET_8BYTE_GUID;
+
+// TODO(wtc): remove this when we drop support for QUIC_VERSION_13.
// Index into the nonce proof of the public reset packet.
// Public resets always have full guids.
const size_t kPublicResetPacketNonceProofOffset =
kGuidOffset + PACKET_8BYTE_GUID;
+// TODO(wtc): remove this when we drop support for QUIC_VERSION_13.
// Index into the rejected sequence number of the public reset packet.
const size_t kPublicResetPacketRejectedSequenceNumberOffset =
kPublicResetPacketNonceProofOffset + kPublicResetNonceSize;
-// TODO(wtc): remove this when we drop support for QUIC_VERSION_13.
-// Size of the old-style public reset packet.
-const size_t kPublicResetPacketOldSize =
- kPublicResetPacketRejectedSequenceNumberOffset +
- PACKET_6BYTE_SEQUENCE_NUMBER;
-
class TestEncrypter : public QuicEncrypter {
public:
virtual ~TestEncrypter() {}
@@ -2533,21 +2534,10 @@ TEST_P(QuicFramerTest, PublicResetPacket) {
expected_error = "Unable to read public flags.";
CheckProcessingFails(packet, i, expected_error,
QUIC_INVALID_PACKET_HEADER);
- } else if (i < kPublicResetPacketNonceProofOffset) {
+ } else if (i < kPublicResetPacketMessageTagOffset) {
expected_error = "Unable to read GUID.";
CheckProcessingFails(packet, i, expected_error,
QUIC_INVALID_PACKET_HEADER);
- } else if (i < kPublicResetPacketRejectedSequenceNumberOffset) {
- expected_error = "Unable to read nonce proof.";
- CheckProcessingFails(packet, i, expected_error,
- QUIC_INVALID_PUBLIC_RST_PACKET);
- } else if (i < kPublicResetPacketOldSize) {
- expected_error = "Unable to read rejected sequence number.";
- CheckProcessingFails(packet, i, expected_error,
- QUIC_INVALID_PUBLIC_RST_PACKET);
- } else if (i == kPublicResetPacketOldSize) {
- // This looks like an old public reset packet, so there won't be an
- // error.
} else {
expected_error = "Unable to read reset message.";
CheckProcessingFails(packet, i, expected_error,
@@ -2556,6 +2546,40 @@ TEST_P(QuicFramerTest, PublicResetPacket) {
}
}
+TEST_P(QuicFramerTest, PublicResetPacketWithTrailingJunk) {
+ unsigned char packet[] = {
+ // public flags (public reset, 8 byte guid)
+ 0x0E,
+ // guid
+ 0x10, 0x32, 0x54, 0x76,
+ 0x98, 0xBA, 0xDC, 0xFE,
+ // message tag (kPRST)
+ 'P', 'R', 'S', 'T',
+ // num_entries (2) + padding
+ 0x02, 0x00, 0x00, 0x00,
+ // tag kRNON
+ 'R', 'N', 'O', 'N',
+ // end offset 8
+ 0x08, 0x00, 0x00, 0x00,
+ // tag kRSEQ
+ 'R', 'S', 'E', 'Q',
+ // end offset 16
+ 0x10, 0x00, 0x00, 0x00,
+ // nonce proof
+ 0x89, 0x67, 0x45, 0x23,
+ 0x01, 0xEF, 0xCD, 0xAB,
+ // rejected sequence number
+ 0xBC, 0x9A, 0x78, 0x56,
+ 0x34, 0x12, 0x00, 0x00,
+ // trailing junk
+ 'j', 'u', 'n', 'k',
+ };
+
+ string expected_error = "Unable to read reset message.";
+ CheckProcessingFails(packet, arraysize(packet), expected_error,
+ QUIC_INVALID_PUBLIC_RST_PACKET);
+}
+
TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) {
unsigned char packet[] = {
// public flags (public reset, 8 byte guid)
@@ -2616,21 +2640,10 @@ TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) {
expected_error = "Unable to read public flags.";
CheckProcessingFails(packet, i, expected_error,
QUIC_INVALID_PACKET_HEADER);
- } else if (i < kPublicResetPacketNonceProofOffset) {
+ } else if (i < kPublicResetPacketMessageTagOffset) {
expected_error = "Unable to read GUID.";
CheckProcessingFails(packet, i, expected_error,
QUIC_INVALID_PACKET_HEADER);
- } else if (i < kPublicResetPacketRejectedSequenceNumberOffset) {
- expected_error = "Unable to read nonce proof.";
- CheckProcessingFails(packet, i, expected_error,
- QUIC_INVALID_PUBLIC_RST_PACKET);
- } else if (i < kPublicResetPacketOldSize) {
- expected_error = "Unable to read rejected sequence number.";
- CheckProcessingFails(packet, i, expected_error,
- QUIC_INVALID_PUBLIC_RST_PACKET);
- } else if (i == kPublicResetPacketOldSize) {
- // This looks like an old public reset packet, so there won't be an
- // error.
} else {
expected_error = "Unable to read reset message.";
CheckProcessingFails(packet, i, expected_error,
« no previous file with comments | « net/quic/quic_framer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698