#3563: Correct max string length for reading SystemChat packets

This commit is contained in:
md_5 2023-11-13 20:09:48 +13:00
parent 16298a75f2
commit 0925c06f9b
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
2 changed files with 7 additions and 2 deletions

View File

@ -79,6 +79,11 @@ public abstract class DefinedPacket
}
public static BaseComponent readBaseComponent(ByteBuf buf, int protocolVersion)
{
return readBaseComponent( buf, Short.MAX_VALUE, protocolVersion );
}
public static BaseComponent readBaseComponent(ByteBuf buf, int maxStringLength, int protocolVersion)
{
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 )
{
@ -88,7 +93,7 @@ public abstract class DefinedPacket
return ComponentSerializer.deserialize( json );
} else
{
String string = readString( buf );
String string = readString( buf, maxStringLength );
return ComponentSerializer.deserialize( string );
}

View File

@ -24,7 +24,7 @@ public class SystemChat extends DefinedPacket
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
message = readBaseComponent( buf, protocolVersion );
message = readBaseComponent( buf, 262144, protocolVersion );
position = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 ) ? ( ( buf.readBoolean() ) ? ChatMessageType.ACTION_BAR.ordinal() : 0 ) : readVarInt( buf );
}