From 4aa035fa957cee3d64eb2b061879d216481f3573 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sat, 7 May 2022 14:59:20 -0700 Subject: [PATCH] Do not accept invalid client settings --- ...o-not-accept-invalid-client-settings.patch | 24 +++++++++++++++++++ .../Replace-player-chunk-loader-system.patch | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 patches/server/Do-not-accept-invalid-client-settings.patch diff --git a/patches/server/Do-not-accept-invalid-client-settings.patch b/patches/server/Do-not-accept-invalid-client-settings.patch new file mode 100644 index 0000000000..3a8b503f8b --- /dev/null +++ b/patches/server/Do-not-accept-invalid-client-settings.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf +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); + } + diff --git a/patches/server/Replace-player-chunk-loader-system.patch b/patches/server/Replace-player-chunk-loader-system.patch index e6504a2e54..8e47816821 100644 --- a/patches/server/Replace-player-chunk-loader-system.patch +++ b/patches/server/Replace-player-chunk-loader-system.patch @@ -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() {