From a6a9814163dd8c5131552bd1321c41a6287978fd Mon Sep 17 00:00:00 2001 From: ORelio Date: Tue, 7 Jul 2015 22:43:27 +0200 Subject: [PATCH] MC 1.7: Skip potential extra data in tab-list items See issue #84 for more info --- MinecraftClient/Protocol/Handlers/Protocol17.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol17.cs b/MinecraftClient/Protocol/Handlers/Protocol17.cs index 7d74e80b..63580074 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol17.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol17.cs @@ -90,9 +90,11 @@ namespace MinecraftClient.Protocol.Handlers handler.OnTextReceived(ChatParser.ParseText(readNextString())); break; case 0x38: - string name = readNextString(); + int name_len = readNextVarInt(); + string name = readNextString(name_len); bool online = readNextBool(); short ping = readNextShort(); + readData(size - getVarInt(id).Length - getVarInt(name.Length).Length - name_len - 3); //Skip extradata Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray()); if (online) { @@ -176,11 +178,13 @@ namespace MinecraftClient.Protocol.Handlers /// /// Read a string from the network /// + /// String length /// The string - private string readNextString() + private string readNextString(int length = -1) { - int length = readNextVarInt(); + if (length < 0) + length = readNextVarInt(); if (length > 0) { byte[] cache = new byte[length];