aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0824-Do-not-accept-invalid-client-settings.patch
blob: 13369cde6796fa0c08f964b9e72e64ba3c069e5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 4f0c8c4a7c20806fba7cf66ad06b0dcb5c7aaf76..400aa2f226df3cab4f0289ba23eb5de96c3daa97 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3453,6 +3453,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
     @Override
     public void handleClientInformation(ServerboundClientInformationPacket packet) {
         PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
+        // 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);
     }