Do not accept invalid client settings

This commit is contained in:
Spottedleaf 2022-05-07 14:59:20 -07:00
parent 7483a45e55
commit 4aa035fa95
2 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,24 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 7 May 2022 14:58:53 -0700
Subject: [PATCH] Do not accept invalid client settings
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@Override
public void handleClientInformation(ServerboundClientInformationPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
+ // Paper start - do not accept invalid information
+ if (packet.viewDistance() < 0) {
+ LOGGER.warn("Disconnecting " + this.player.getScoreboardName() + " for invalid view distance: " + packet.viewDistance());
+ this.disconnect("Invalid client settings", PlayerKickEvent.Cause.ILLEGAL_ACTION);
+ return;
+ }
+ // Paper end - do not accept invalid information
this.player.updateOptions(packet);
}

View File

@ -1066,7 +1066,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ protected int getClientViewDistance() {
+ return this.player.clientViewDistance == null ? -1 : this.player.clientViewDistance.intValue();
+ return this.player.clientViewDistance == null ? -1 : Math.max(0, this.player.clientViewDistance.intValue());
+ }
+
+ public void update() {