mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 18:34:56 -04:00
network: fix string reading length check
This commit is contained in:
parent
aded63eba9
commit
42d9c9b592
@ -109,11 +109,11 @@ public class InByteBuffer {
|
||||
}
|
||||
|
||||
public String readString() {
|
||||
byte[] data = readBytes(readVarInt());
|
||||
if (data.length > ProtocolDefinition.STRING_MAX_LEN) {
|
||||
throw new IllegalArgumentException(String.format("String max string length exceeded %d > %d", data.length, ProtocolDefinition.STRING_MAX_LEN));
|
||||
String string = new String(readBytes(readVarInt()), StandardCharsets.UTF_8);
|
||||
if (string.length() > ProtocolDefinition.STRING_MAX_LEN) {
|
||||
throw new IllegalArgumentException(String.format("String max string length exceeded %d > %d", string.length(), ProtocolDefinition.STRING_MAX_LEN));
|
||||
}
|
||||
return new String(data, StandardCharsets.UTF_8);
|
||||
return string;
|
||||
}
|
||||
|
||||
public long readVarLong() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user