#3268: Correct plugin message size check

This commit is contained in:
Outfluencer 2022-03-19 10:03:29 +11:00 committed by md_5
parent 978e68fc74
commit 410f64bc9f
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -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 );
}