From f28caff92752681593137edea91b8fa908995d8e Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 12 Jan 2024 19:33:17 +0100 Subject: [PATCH] Limit ResourceLocation length to nbt string tag length --- ...57-Validate-ResourceLocation-in-NBT-reading.patch | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/patches/server/1057-Validate-ResourceLocation-in-NBT-reading.patch b/patches/server/1057-Validate-ResourceLocation-in-NBT-reading.patch index 645e44224..ab785a22f 100644 --- a/patches/server/1057-Validate-ResourceLocation-in-NBT-reading.patch +++ b/patches/server/1057-Validate-ResourceLocation-in-NBT-reading.patch @@ -21,6 +21,18 @@ index 18fad4f083862ace2bc56579883f548f6d697091..80083fed4b44b9d433925f09db83e559 if (optional.isEmpty()) { return Blocks.AIR.defaultBlockState(); } else { +diff --git a/src/main/java/net/minecraft/resources/ResourceLocation.java b/src/main/java/net/minecraft/resources/ResourceLocation.java +index 38e2a8cec48bc779b8154d6d719031f457a2403e..9024622a41fdc774713481973c1419a8d18cce93 100644 +--- a/src/main/java/net/minecraft/resources/ResourceLocation.java ++++ b/src/main/java/net/minecraft/resources/ResourceLocation.java +@@ -31,6 +31,7 @@ public class ResourceLocation implements Comparable { + private final String path; + + protected ResourceLocation(String namespace, String path, @Nullable ResourceLocation.Dummy extraData) { ++ if (io.netty.buffer.ByteBufUtil.utf8MaxBytes(namespace + ":" + path) > 2 * Short.MAX_VALUE + 1) throw new ResourceLocationException("Resource location too long: " + namespace + ":" + path); // Paper - Validate ResourceLocation + this.namespace = namespace; + this.path = path; + } diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java index 00389d7ec3e8b059d5591a2019ba240fda2901fe..6cfce9755dd464a7afb01f9032e567ce3bcd5bc5 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java