From 1ea70a302b87ed8d99581bc8ddd96be704b40220 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 6 Mar 2019 15:52:49 -0800 Subject: [PATCH] ignore protocol minor version 0 The change from 0 -> 1 included incompatible changes to CMD_BEACON and several others. Ignore any UDP messages (beacon or search), and disconnect any TCP peers, with version==0. --- pvtoolsSrc/pvlist.cpp | 4 ++++ src/remote/blockingUDPTransport.cpp | 4 ++++ src/remote/codec.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pvtoolsSrc/pvlist.cpp b/pvtoolsSrc/pvlist.cpp index 573ebe3..ddc42ac 100644 --- a/pvtoolsSrc/pvlist.cpp +++ b/pvtoolsSrc/pvlist.cpp @@ -120,6 +120,10 @@ bool processSearchResponse(osiSockAddr const & responseFrom, ByteBuffer & receiv // second byte version int8 version = receiveBuffer.getByte(); + if(version == 0) { + // 0 -> 1 included incompatible changes + return false; + } // only data for UDP int8 flags = receiveBuffer.getByte(); diff --git a/src/remote/blockingUDPTransport.cpp b/src/remote/blockingUDPTransport.cpp index db0e366..77c0797 100644 --- a/src/remote/blockingUDPTransport.cpp +++ b/src/remote/blockingUDPTransport.cpp @@ -341,6 +341,10 @@ bool BlockingUDPTransport::processBuffer(Transport::shared_pointer const & trans // second byte version int8 version = receiveBuffer->getByte(); + if(version==0) { + // 0 -> 1 included incompatible changes + return false; + } int8 flags = receiveBuffer->getByte(); if (flags & 0x80) diff --git a/src/remote/codec.cpp b/src/remote/codec.cpp index 0ee4c11..e4ad3a4 100644 --- a/src/remote/codec.cpp +++ b/src/remote/codec.cpp @@ -159,12 +159,12 @@ void AbstractCodec::processHeader() { _payloadSize = _socketBuffer.getInt(); // check magic code - if (magicCode != PVA_MAGIC) + if (magicCode != PVA_MAGIC || _version==0) { LOG(logLevelError, - "Invalid header received from the client at %s:%d: %s.," - " disconnecting...", - __FILE__, __LINE__, inetAddressToString(*getLastReadBufferSocketAddress()).c_str()); + "Invalid header received from the client : %s %02x%02x%02x%02x disconnecting...", + inetAddressToString(*getLastReadBufferSocketAddress()).c_str(), + unsigned(magicCode), unsigned(_version), unsigned(_flags), unsigned(_command)); invalidDataStreamHandler(); throw invalid_data_stream_exception("invalid header received"); }