From 06c2669cf6b03feb15990004087e882ac846b061 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 3 Jan 2015 22:23:49 +0100 Subject: Protocols: Ignore garbage data at the end of PluginMessage packets. Fixes #1692. --- src/Protocol/Protocol18x.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/Protocol/Protocol18x.cpp') diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index 72827ac47..21b098735 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -2331,6 +2331,16 @@ void cProtocol180::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) if (Channel.substr(0, 3) == "MC|") { HandleVanillaPluginMessage(a_ByteBuffer, Channel); + + // Skip any unread data (vanilla sometimes sends garbage at the end of a packet; #1692): + if (a_ByteBuffer.GetReadableSpace() > 1) + { + LOGD("Protocol 1.8: Skipping garbage data at the end of a vanilla PluginMessage packet, %u bytes", + a_ByteBuffer.GetReadableSpace() - 1 + ); + a_ByteBuffer.SkipRead(a_ByteBuffer.GetReadableSpace() - 1); + } + return; } -- cgit v1.2.3