From 4400b0f83e242fe68f60b93e6fef3d2fd1db184d Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 22 Sep 2021 14:32:49 +0100 Subject: [PATCH] Fix #1114 - Ensure short is correctly cast to int, as we're using it as if it were unsigned --- .../src/main/java/com/sk89q/jnbt/NBTInputStream.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java index 301a96e08..697adc003 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java @@ -494,7 +494,7 @@ public final class NBTInputStream implements Closeable { is.readFully(bytes); return (bytes); case NBTConstants.TYPE_STRING: - length = is.readShort(); + length = is.readShort() & 0xFFFF; bytes = new byte[length]; is.readFully(bytes); return (new String(bytes, NBTConstants.CHARSET)); @@ -597,7 +597,7 @@ public final class NBTInputStream implements Closeable { is.readFully(bytes); return new ByteArrayTag(bytes); case NBTConstants.TYPE_STRING: - length = is.readShort(); + length = is.readShort() & 0xFFFF; bytes = new byte[length]; is.readFully(bytes); return new StringTag(new String(bytes, NBTConstants.CHARSET));