From 83d76084f1f4c3e97fc65c0367c0dd6598db5d56 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 25 Aug 2015 17:14:41 -0700 Subject: [PATCH] don't process packets in Connection without handshake --- libraries/networking/src/udt/Connection.cpp | 11 +++++++++++ libraries/networking/src/udt/Connection.h | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/Connection.cpp b/libraries/networking/src/udt/Connection.cpp index d5b84ce070..044eb0780f 100644 --- a/libraries/networking/src/udt/Connection.cpp +++ b/libraries/networking/src/udt/Connection.cpp @@ -313,6 +313,11 @@ SequenceNumber Connection::nextACK() const { bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber, int packetSize, int payloadSize) { + if (!_hasReceivedHandshake) { + // refuse to process any packets until we've received the handshake + return false; + } + _hasReceivedFirstPacket = true; // check if this is a packet pair we should estimate bandwidth from, or just a regular packet @@ -382,6 +387,12 @@ bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber, in } void Connection::processControl(std::unique_ptr controlPacket) { + + if (!_hasReceivedHandshake && controlPacket->getType() != ControlPacket::Handshake) { + // we refuse to process any packets until the handshake is received + return; + } + // Simple dispatch to control packets processing methods based on their type switch (controlPacket->getType()) { case ControlPacket::ACK: diff --git a/libraries/networking/src/udt/Connection.h b/libraries/networking/src/udt/Connection.h index 8b52b1cf5e..e1933a0f02 100644 --- a/libraries/networking/src/udt/Connection.h +++ b/libraries/networking/src/udt/Connection.h @@ -63,7 +63,7 @@ public: void sync(); // rate control method, fired by Socket for all connections on SYN interval - // return indicates if this packet was a duplicate + // return indicates if this packet should be processed bool processReceivedSequenceNumber(SequenceNumber sequenceNumber, int packetSize, int payloadSize); void processControl(std::unique_ptr controlPacket);