diff --git a/src/main/java/net/minestom/server/utils/PacketUtils.java b/src/main/java/net/minestom/server/utils/PacketUtils.java index f3e33007d..12f72b697 100644 --- a/src/main/java/net/minestom/server/utils/PacketUtils.java +++ b/src/main/java/net/minestom/server/utils/PacketUtils.java @@ -172,6 +172,9 @@ public final class PacketUtils { if (compressed) { final int dataLength = readBuffer.readVarInt(); final int payloadLength = packetLength - (readBuffer.readerOffset() - readerStart); + if (payloadLength < 0) { + throw new DataFormatException("Negative payload length " + payloadLength); + } if (dataLength == 0) { // Data is too small to be compressed, payload is following decompressedSize = payloadLength;