3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 02:50:09 +01:00
Paper/patches/server/0346-Validate-PickItem-Packet-and-kick-for-invalid.patch

27 Zeilen
1.6 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 2 May 2020 03:09:46 -0400
Subject: [PATCH] Validate PickItem Packet and kick for invalid
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2024-10-23 17:13:43 +02:00
index fd5ad700154a7b75f2ecff6a8d47f6d75ac789e4..7d3a64ad036470e9cd540131c2c3a58d871bc392 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2024-10-23 17:13:43 +02:00
@@ -898,7 +898,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2021-06-11 14:02:28 +02:00
@Override
public void handlePickItem(ServerboundPickItemPacket packet) {
2023-06-08 00:58:10 +02:00
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
- this.player.getInventory().pickSlot(packet.getSlot());
2021-06-11 14:02:28 +02:00
+ // Paper start - validate pick item position
+ if (!(packet.getSlot() >= 0 && packet.getSlot() < this.player.getInventory().items.size())) {
2021-06-11 14:02:28 +02:00
+ ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
2024-06-14 14:11:52 +02:00
+ this.disconnect(Component.literal("Invalid hotbar selection (Hacking?)"));
2021-06-11 14:02:28 +02:00
+ return;
+ }
+ this.player.getInventory().pickSlot(packet.getSlot()); // Paper - Diff above if changed
+ // Paper end - validate pick item position
2024-10-23 16:04:01 +02:00
int i = this.player.getInventory().selected;
this.player.connection.send(this.player.getInventory().createInventoryUpdatePacket(i));