diff options
author | Mat <[email protected]> | 2019-12-23 09:31:19 +0200 |
---|---|---|
committer | Zach <[email protected]> | 2019-12-23 01:31:19 -0600 |
commit | 3adc8eb6e6a4b9f174ff3719af62f34374360619 (patch) | |
tree | cef28c62402d6ac75715d55cb481ac9f19c34fbb | |
parent | e38aa244d4a2b669aa5f7fb32fd71b2f3363631b (diff) | |
download | Paper-3adc8eb6e6a4b9f174ff3719af62f34374360619.tar.gz Paper-3adc8eb6e6a4b9f174ff3719af62f34374360619.zip |
Backport disconnect exploit fixes to 1.13.2 (#2768)
-rw-r--r-- | Spigot-Server-Patches/0447-Backport-SPIGOT-5428-Better-handling-of-some-ItemMet.patch | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0447-Backport-SPIGOT-5428-Better-handling-of-some-ItemMet.patch b/Spigot-Server-Patches/0447-Backport-SPIGOT-5428-Better-handling-of-some-ItemMet.patch new file mode 100644 index 0000000000..de0b8b8212 --- /dev/null +++ b/Spigot-Server-Patches/0447-Backport-SPIGOT-5428-Better-handling-of-some-ItemMet.patch @@ -0,0 +1,105 @@ +From af4651f62f0e4ebd4af0dac08b03c94550da301c Mon Sep 17 00:00:00 2001 +From: Mathias <[email protected]> +Date: Mon, 16 Dec 2019 19:11:10 +0200 +Subject: [PATCH] Backport SPIGOT-5428: Better handling of some ItemMeta + + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java +index 2f72f0ce..ffc24634 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java +@@ -53,7 +53,14 @@ public class CraftMetaBanner extends CraftMetaItem implements BannerMeta { + NBTTagList patterns = entityTag.getList(PATTERNS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); + for (int i = 0; i < Math.min(patterns.size(), 20); i++) { + NBTTagCompound p = patterns.getCompound(i); +- this.patterns.add(new Pattern(DyeColor.getByWoolData((byte) p.getInt(COLOR.NBT)), PatternType.getByIdentifier(p.getString(PATTERN.NBT)))); ++ // Paper start - Backport SPIGOT-5428 ++ DyeColor color = DyeColor.getByWoolData((byte) p.getInt(COLOR.NBT)); ++ PatternType pattern = PatternType.getByIdentifier(p.getString(PATTERN.NBT)); ++ ++ if (color != null && pattern != null) { ++ this.patterns.add(new Pattern(color, pattern)); ++ } ++ // Paper end + } + } + } +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java +index 267581ec..7adbc4ea 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java +@@ -36,7 +36,13 @@ class CraftMetaCharge extends CraftMetaItem implements FireworkEffectMeta { + super(tag); + + if (tag.hasKey(EXPLOSION.NBT)) { +- effect = CraftMetaFirework.getEffect(tag.getCompound(EXPLOSION.NBT)); ++ // Paper start - Backport SPIGOT-5428 ++ try { ++ effect = CraftMetaFirework.getEffect(tag.getCompound(EXPLOSION.NBT)); ++ } catch (IllegalArgumentException ex) { ++ // Ignore invalid effects ++ } ++ // Paper end + } + } + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java +index b82e2fdf..957c144b 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java +@@ -93,7 +93,13 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { + List<FireworkEffect> effects = this.effects = new ArrayList<FireworkEffect>(fireworkEffects.size()); + + for (int i = 0; i < fireworkEffects.size(); i++) { +- effects.add(getEffect((NBTTagCompound) fireworkEffects.get(i))); ++ // Paper start - Backport SPIGOT-5428 ++ try { ++ effects.add(getEffect((NBTTagCompound) fireworkEffects.get(i))); ++ } catch (IllegalArgumentException ex) { ++ // Ignore invalid effects ++ } ++ // Paper end - Backport SPIGOT-5428 + } + } + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java +index e5b1a730..8a706aba 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java +@@ -66,7 +66,13 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { + } + + if (display.hasKey(MAP_COLOR.NBT)) { +- color = Color.fromRGB(display.getInt(MAP_COLOR.NBT)); ++ // Paper start - Backport SPIGOT-5428 ++ try { ++ color = Color.fromRGB(display.getInt(MAP_COLOR.NBT)); ++ } catch (IllegalArgumentException ex) { ++ // Invalid colour ++ } ++ // Paper end + } + } + } +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java +index 29fbdcc8..9a7dec54 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java +@@ -62,7 +62,13 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { + type = CraftPotionUtil.toBukkit(tag.getString(DEFAULT_POTION.NBT)); + } + if (tag.hasKey(POTION_COLOR.NBT)) { +- color = Color.fromRGB(tag.getInt(POTION_COLOR.NBT)); ++ // Paper start - Backport SPIGOT-5428 ++ try { ++ color = Color.fromRGB(tag.getInt(POTION_COLOR.NBT)); ++ } catch (IllegalArgumentException ex) { ++ // Invalid colour ++ } ++ // Paper end + } + if (tag.hasKey(POTION_EFFECTS.NBT)) { + NBTTagList list = tag.getList(POTION_EFFECTS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); +-- +2.24.1 + |