Skip to content

Commit

Permalink
🔒 Fix username length check on login packets
Browse files Browse the repository at this point in the history
  • Loading branch information
YvanMazy committed Apr 9, 2024
1 parent 0fe628e commit aa85ab5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public record LoginSuccessPacket(UUID uuid, String username, Property[] properti

public LoginSuccessPacket(final @NotNull ByteBuf buf) {
this(readUUID(buf),
readString(buf),
readString(buf, 16),
readArray(buf,
Property[]::new,
sub -> new Property(readString(sub), readString(sub), sub.readBoolean() ? readString(buf) : null),
Expand All @@ -49,7 +49,7 @@ public LoginSuccessPacket(final @NotNull ByteBuf buf) {
@Override
public void write(final @NotNull ByteBuf buf) {
writeUUID(buf, this.uuid);
writeString(buf, this.username);
writeString(buf, this.username, 16);
if (this.properties == null) {
writeVarInt(buf, 0);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
public record LoginStartPacket(String name, UUID uuid) implements ServerboundPacket {

public LoginStartPacket(final @NotNull ByteBuf buf) {
this(readString(buf), readUUID(buf));
this(readString(buf, 16), readUUID(buf));
}

@Override
Expand All @@ -54,7 +54,7 @@ public void handle(final @NotNull PlayerConnection connection) {

@Override
public void write(final @NotNull ByteBuf buf) {
writeString(buf, this.name);
writeString(buf, this.name, 16);
writeUUID(buf, this.uuid);
}

Expand Down

0 comments on commit aa85ab5

Please sign in to comment.