summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2017-05-14 09:25:25 +1000
committermd_5 <git@md-5.net>2017-05-14 09:25:25 +1000
commitfcc5dcce546ca33fc5ce0fcd971593f237afea4f (patch)
tree6dc176300422bbf13e6d64cb30cca3a0ef737d06 /nms-patches
parent2b6c9f40aef19b5366a8ecd6bf2bb9900ce3c684 (diff)
downloadcraftbukkit-fcc5dcce546ca33fc5ce0fcd971593f237afea4f.tar
craftbukkit-fcc5dcce546ca33fc5ce0fcd971593f237afea4f.tar.gz
craftbukkit-fcc5dcce546ca33fc5ce0fcd971593f237afea4f.tar.lz
craftbukkit-fcc5dcce546ca33fc5ce0fcd971593f237afea4f.tar.xz
craftbukkit-fcc5dcce546ca33fc5ce0fcd971593f237afea4f.zip
SPIGOT-3235: Disconnect for payload errors
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/PlayerConnection.patch42
1 files changed, 30 insertions, 12 deletions
diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch
index 8948303b..e4b9ae11 100644
--- a/nms-patches/PlayerConnection.patch
+++ b/nms-patches/PlayerConnection.patch
@@ -1156,7 +1156,7 @@
+ if (packetplayinwindowclick.b() < -1 && packetplayinwindowclick.b() != -999) {
+ return;
+ }
-
++
+ InventoryView inventory = this.player.activeContainer.getBukkitView();
+ SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.b());
+
@@ -1412,7 +1412,7 @@
+ }
+ return;
+ }
-+
+
+ if (event instanceof CraftItemEvent) {
+ // Need to update the inventory on crafting to
+ // correctly support custom recipes
@@ -1649,25 +1649,43 @@
}
} else if ("MC|PickItem".equals(s)) {
packetdataserializer = packetplayincustompayload.b();
-@@ -1323,9 +2427,31 @@
+@@ -1321,11 +2425,49 @@
+ this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
+ } catch (Exception exception7) {
PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7);
++ this.disconnect("Invalid pick item!"); // CraftBukkit
}
}
+ // CraftBukkit start
+ else if (packetplayincustompayload.a().equals("REGISTER")) {
-+ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
-+ for (String channel : channels.split("\0")) {
-+ getPlayer().addChannel(channel);
++ try {
++ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
++ for (String channel : channels.split("\0")) {
++ getPlayer().addChannel(channel);
++ }
++ } catch (Exception ex) {
++ PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex);
++ this.disconnect("Invalid payload REGISTER!");
+ }
+ } else if (packetplayincustompayload.a().equals("UNREGISTER")) {
-+ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
-+ for (String channel : channels.split("\0")) {
-+ getPlayer().removeChannel(channel);
++ try {
++ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
++ for (String channel : channels.split("\0")) {
++ getPlayer().removeChannel(channel);
++ }
++ } catch (Exception ex) {
++ PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex);
++ this.disconnect("Invalid payload UNREGISTER!");
+ }
+ } else {
-+ byte[] data = new byte[packetplayincustompayload.b().readableBytes()];
-+ packetplayincustompayload.b().readBytes(data);
-+ server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.a(), data);
++ try {
++ byte[] data = new byte[packetplayincustompayload.b().readableBytes()];
++ packetplayincustompayload.b().readBytes(data);
++ server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.a(), data);
++ } catch (Exception ex) {
++ PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex);
++ this.disconnect("Invalid custom payload!");
++ }
+ }
+ // CraftBukkit end
}