From 7d268912f1ee09b4e146208a4dd84dbf81ba335d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Aug 2013 00:58:25 +0100 Subject: Packet headers are not zero-encoded so don't try to zero-decode these in PacketPool.GetType() Instead adjusts code with that from Packet.BuildHeader(byte[], ref int, ref int):Header in libomv This stops packet decoding failures with agent UUIDs that contain 00 in their earlier parts (e.g. b0b0b0b0-0000-0000-0000-000000000211) Thanks to lkalif for pointing this out. --- .../Region/ClientStack/Linden/UDP/PacketPool.cs | 25 ++++++++-------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs index 1fdc410..5a2bcee 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs @@ -145,39 +145,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP return packet; } - // private byte[] decoded_header = new byte[10]; private static PacketType GetType(byte[] bytes) { - byte[] decoded_header = new byte[10 + 8]; ushort id; PacketFrequency freq; + bool isZeroCoded = (bytes[0] & Helpers.MSG_ZEROCODED) != 0; - if ((bytes[0] & Helpers.MSG_ZEROCODED) != 0) + if (bytes[6] == 0xFF) { - Helpers.ZeroDecode(bytes, 16, decoded_header); - } - else - { - Buffer.BlockCopy(bytes, 0, decoded_header, 0, 10); - } - - if (decoded_header[6] == 0xFF) - { - if (decoded_header[7] == 0xFF) + if (bytes[7] == 0xFF) { - id = (ushort) ((decoded_header[8] << 8) + decoded_header[9]); freq = PacketFrequency.Low; + if (isZeroCoded && bytes[8] == 0) + id = bytes[10]; + else + id = (ushort)((bytes[8] << 8) + bytes[9]); } else { - id = decoded_header[7]; freq = PacketFrequency.Medium; + id = bytes[7]; } } else { - id = decoded_header[6]; freq = PacketFrequency.High; + id = bytes[6]; } return Packet.GetType(id, freq); -- cgit v1.1