From 410f64bc9f19d10838dd142df3edbef6bc221bb8 Mon Sep 17 00:00:00 2001 From: Outfluencer <48880402+Outfluencer@users.noreply.github.com> Date: Sat, 19 Mar 2022 10:03:29 +1100 Subject: [PATCH] #3268: Correct plugin message size check --- .../java/net/md_5/bungee/protocol/packet/PluginMessage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java index 6f9fc6c3..70b292f0 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java @@ -60,8 +60,8 @@ public class PluginMessage extends DefinedPacket public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { tag = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( readString( buf ) ) : readString( buf, 20 ); - int maxSize = direction == ProtocolConstants.Direction.TO_SERVER ? Short.MAX_VALUE : 0x100000; - Preconditions.checkArgument( buf.readableBytes() < maxSize ); + int maxSize = ( direction == ProtocolConstants.Direction.TO_SERVER ) ? Short.MAX_VALUE : 0x100000; + Preconditions.checkArgument( buf.readableBytes() <= maxSize, "Payload too large" ); data = new byte[ buf.readableBytes() ]; buf.readBytes( data ); }