From af61e5fa1e0c5422b9b7c9b5ec41e2e845648e3d 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 --- .../Validate-ResourceLocation-in-NBT-reading.patch | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/patches/server/Validate-ResourceLocation-in-NBT-reading.patch b/patches/server/Validate-ResourceLocation-in-NBT-reading.patch index 2c7cd61552..62ad8bf67f 100644 --- a/patches/server/Validate-ResourceLocation-in-NBT-reading.patch +++ b/patches/server/Validate-ResourceLocation-in-NBT-reading.patch @@ -21,6 +21,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/resources/ResourceLocation.java ++++ b/src/main/java/net/minecraft/resources/ResourceLocation.java +@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java