From fe13ae6da987ceac51e8829a8ec19646673d81ce Mon Sep 17 00:00:00 2001 From: Samsuik <40902469+Samsuik@users.noreply.github.com> Date: Fri, 18 Aug 2023 16:50:16 +0100 Subject: [PATCH] Fix banner crash exploit --- .../0014-Fix-some-creative-exploits.patch | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/patches/server/0014-Fix-some-creative-exploits.patch b/patches/server/0014-Fix-some-creative-exploits.patch index ae0ebfb..1718389 100644 --- a/patches/server/0014-Fix-some-creative-exploits.patch +++ b/patches/server/0014-Fix-some-creative-exploits.patch @@ -1,4 +1,4 @@ -From 4adef32d2418f5c1e1891346b655557e5850790e Mon Sep 17 00:00:00 2001 +From 04c6b026af4aad5996388baee237f473969290cb Mon Sep 17 00:00:00 2001 From: Samsuik <40902469+Samsuik@users.noreply.github.com> Date: Tue, 9 May 2023 16:43:24 +0100 Subject: [PATCH] Fix some creative exploits @@ -260,6 +260,56 @@ index 863e9d8e9..0b3fe9930 100644 entityliving.heal((float) j, RegainReason.MAGIC); // CraftBukkit } +diff --git a/src/main/java/net/minecraft/server/TileEntityBanner.java b/src/main/java/net/minecraft/server/TileEntityBanner.java +index aa5ad2ef0..8778e1ce9 100644 +--- a/src/main/java/net/minecraft/server/TileEntityBanner.java ++++ b/src/main/java/net/minecraft/server/TileEntityBanner.java +@@ -19,11 +19,7 @@ public class TileEntityBanner extends TileEntity { + NBTTagCompound nbttagcompound = itemstack.getTag().getCompound("BlockEntityTag"); + + if (nbttagcompound.hasKey("Patterns")) { +- this.patterns = (NBTTagList) nbttagcompound.getList("Patterns", 10).clone(); +- // CraftBukkit start +- while (this.patterns.size() > 20) { +- this.patterns.a(20); // PAIL Rename remove +- } ++ this.patterns = loadPatternsFromCompound(nbttagcompound); // Blossom - avoid o(n^2) removal of unnecessary patterns + // CraftBukkit end + } + +@@ -42,6 +38,18 @@ public class TileEntityBanner extends TileEntity { + this.g = true; + } + ++ // Blossom start ++ private NBTTagList loadPatternsFromCompound(NBTTagCompound nbttagcompound) { ++ NBTTagList list = nbttagcompound.getList("Patterns", 10); ++ NBTTagList patterns = new NBTTagList(); ++ int min = Math.min(list.size(), 20); ++ for (int i = 0; i < min; ++i) { ++ patterns.add(list.get(i)); ++ } ++ return patterns; ++ } ++ // Blossom end ++ + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + a(nbttagcompound, this.color, this.patterns); +@@ -58,12 +66,7 @@ public class TileEntityBanner extends TileEntity { + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + this.color = nbttagcompound.getInt("Base"); +- this.patterns = nbttagcompound.getList("Patterns", 10); +- // CraftBukkit start +- while (this.patterns.size() > 20) { +- this.patterns.a(20); // PAIL Rename remove +- } +- // CraftBukkit end ++ this.patterns = loadPatternsFromCompound(nbttagcompound); // Blossom - avoid o(n^2) removal of unnecessary patterns + this.h = null; + this.i = null; + this.j = null; diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java index 58014c5f1..51b7cc90a 100644 --- a/src/main/java/net/minecraft/server/TileEntitySkull.java