Apply stricter length limits to client strings

Also bump snapshot version and remove redundant file header
This commit is contained in:
md_5 2021-05-21 08:16:51 +10:00
parent 5823f47467
commit e5ded9a2fb
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
6 changed files with 5 additions and 9 deletions

View File

@ -34,7 +34,7 @@ public class ProtocolConstants
public static final int MINECRAFT_1_16_2 = 751; public static final int MINECRAFT_1_16_2 = 751;
public static final int MINECRAFT_1_16_3 = 753; public static final int MINECRAFT_1_16_3 = 753;
public static final int MINECRAFT_1_16_4 = 754; public static final int MINECRAFT_1_16_4 = 754;
public static final int MINECRAFT_1_17 = 1073741851; public static final int MINECRAFT_1_17 = 1073741852;
public static final List<String> SUPPORTED_VERSIONS; public static final List<String> SUPPORTED_VERSIONS;
public static final List<Integer> SUPPORTED_VERSION_IDS; public static final List<Integer> SUPPORTED_VERSION_IDS;

View File

@ -40,7 +40,7 @@ public class Chat extends DefinedPacket
@Override @Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
message = readString( buf ); message = readString( buf, 256 );
if ( direction == ProtocolConstants.Direction.TO_CLIENT ) if ( direction == ProtocolConstants.Direction.TO_CLIENT )
{ {
position = buf.readByte(); position = buf.readByte();

View File

@ -28,7 +28,7 @@ public class ClientSettings extends DefinedPacket
@Override @Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
locale = readString( buf ); locale = readString( buf, 16 );
viewDistance = buf.readByte(); viewDistance = buf.readByte();
chatFlags = protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ? DefinedPacket.readVarInt( buf ) : buf.readUnsignedByte(); chatFlags = protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ? DefinedPacket.readVarInt( buf ) : buf.readUnsignedByte();
chatColours = buf.readBoolean(); chatColours = buf.readBoolean();

View File

@ -24,7 +24,7 @@ public class Handshake extends DefinedPacket
public void read(ByteBuf buf) public void read(ByteBuf buf)
{ {
protocolVersion = readVarInt( buf ); protocolVersion = readVarInt( buf );
host = readString( buf ); host = readString( buf, 255 );
port = buf.readUnsignedShort(); port = buf.readUnsignedShort();
requestedProtocol = readVarInt( buf ); requestedProtocol = readVarInt( buf );
} }

View File

@ -1,7 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.md_5.bungee.protocol.packet; package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;

View File

@ -41,7 +41,7 @@ public class TabCompleteRequest extends DefinedPacket
{ {
transactionId = readVarInt( buf ); transactionId = readVarInt( buf );
} }
cursor = readString( buf ); cursor = readString( buf, 32500 );
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 ) if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 )
{ {