diff --git a/tracking/protocol.cpp b/tracking/protocol.cpp index aea3402203..c0cfab40c0 100644 --- a/tracking/protocol.cpp +++ b/tracking/protocol.cpp @@ -79,11 +79,10 @@ pair Protocol::DecodeHeader(vector const // static string Protocol::DecodeAuthPacket(Protocol::PacketType type, vector const & data) { - ASSERT_GREATER_OR_EQUAL(data.size(), sizeof(uint32_t /* header */), ()); switch (type) { case Protocol::PacketType::AuthV0: - return string(begin(data) + sizeof(uint32_t /* header */), end(data)); + return string(begin(data), end(data)); case Protocol::PacketType::DataV0: break; } return string(); @@ -92,11 +91,9 @@ string Protocol::DecodeAuthPacket(Protocol::PacketType type, vector con // static Protocol::DataElementsVec Protocol::DecodeDataPacket(PacketType type, vector const & data) { - ASSERT_GREATER_OR_EQUAL(data.size(), sizeof(uint32_t /* header */), ()); DataElementsVec points; MemReader memReader(data.data(), data.size()); ReaderSource src(memReader); - src.Skip(sizeof(uint32_t /* header */)); switch (type) { case Protocol::PacketType::DataV0: diff --git a/tracking/tracking_tests/protocol_test.cpp b/tracking/tracking_tests/protocol_test.cpp index 3bdbf1798d..268f375f65 100644 --- a/tracking/tracking_tests/protocol_test.cpp +++ b/tracking/tracking_tests/protocol_test.cpp @@ -52,7 +52,8 @@ UNIT_TEST(Protocol_DecodeAuthPacket) TEST_EQUAL(packet.size(), 7, ()); TEST_EQUAL(Protocol::PacketType(packet[0]), Protocol::PacketType::CurrentAuth, ()); - auto result = Protocol::DecodeAuthPacket(Protocol::PacketType::CurrentAuth, packet); + auto payload = vector(begin(packet) + sizeof(uint32_t /* header */), end(packet)); + auto result = Protocol::DecodeAuthPacket(Protocol::PacketType::CurrentAuth, payload); TEST_EQUAL(result, "ABC", ()); } @@ -69,7 +70,8 @@ UNIT_TEST(Protocol_DecodeDataPacket) TEST_EQUAL(packet.size(), 26, ()); TEST_EQUAL(Protocol::PacketType(packet[0]), Protocol::PacketType::CurrentData, ()); - Container result = Protocol::DecodeDataPacket(Protocol::PacketType::CurrentData, packet); + auto payload = vector(begin(packet) + sizeof(uint32_t /* header */), end(packet)); + Container result = Protocol::DecodeDataPacket(Protocol::PacketType::CurrentData, payload); TEST_EQUAL(points.size(), result.size(), ()); for (size_t i = 0; i < points.size(); ++i)