From 1f4358af4bb490ac9c7c3bc66c801c9394094e01 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Tue, 22 Sep 2020 19:17:12 -0400 Subject: [PATCH] Packetizer: Correct packet length check AA(1) + Old format(1) + New Length(2) + New NetID(2) = 6 --- communication/packetizer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/communication/packetizer.cpp b/communication/packetizer.cpp index fe97dce..6ec6231 100644 --- a/communication/packetizer.cpp +++ b/communication/packetizer.cpp @@ -75,12 +75,12 @@ bool Packetizer::input(const std::vector& inputBytes) { packet.network = Network((bytes[5] << 8) | bytes[4]); // Long packets have their netid stored as little endian on bytes 5 and 6 currentIndex += 4; - /* Long packets can't have a length less than 4, because that would indicate a negative payload size. + /* Long packets can't have a length less than 6, because that would indicate a negative payload size. * Unlike the short packet length, the long packet length encompasses everything from the 0xAA to the * end of the payload. The short packet length, for reference, only encompasses the length of the actual * payload, and not the header or checksum. */ - if(packetLength < 4 || packetLength > 4000) { + if(packetLength < 6 || packetLength > 4000) { bytes.pop_front(); EventManager::GetInstance().add(APIEvent::Type::FailedToRead, APIEvent::Severity::Error); state = ReadState::SearchForHeader;