Paper/patches/server/0810-Do-not-accept-invalid-client-settings.patch
Spottedleaf fe54a13b13 Properly call overloaded super onDisconnect
Since the method is overloaded, the call to super (which is changed
to call the overloaded method) without the additional parameters
will result in recursion.
2023-09-26 13:16:24 -07:00

25 lines
1.6 KiB
Diff

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 aa3926339c698038560f3eb2671917c9d5882fee..ba86bc53af2e9574a4fbaaf052df4f4cc5d752bd 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3312,6 +3312,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@Override
public void handleClientInformation(ServerboundClientInformationPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
+ // Paper start - do not accept invalid information
+ if (packet.information().viewDistance() < 0) {
+ LOGGER.warn("Disconnecting " + this.player.getScoreboardName() + " for invalid view distance: " + packet.information().viewDistance());
+ this.disconnect("Invalid client settings", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION);
+ return;
+ }
+ // Paper end - do not accept invalid information
this.player.updateOptions(packet.information());
this.connection.channel.attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).set(net.kyori.adventure.translation.Translator.parseLocale(packet.information().language())); // Paper
}