Validate uncompressed packet size (#1527)

* Validate uncompressed packet size

* Fix debug using incorrect value
This commit is contained in:
Jones
2025-03-14 10:26:59 -05:00
committed by GitHub
parent c9aa1cca09
commit d9f1016bd5

View File

@@ -52,6 +52,9 @@ public class MinecraftCompressDecoder extends MessageToMessageDecoder<ByteBuf> {
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
int claimedUncompressedSize = ProtocolUtils.readVarInt(in);
if (claimedUncompressedSize == 0) {
int actualUncompressedSize = in.readableBytes();
checkFrame(actualUncompressedSize < threshold, "Actual uncompressed size %s is greater than"
+ " threshold %s", actualUncompressedSize, threshold);
// This message is not compressed.
out.add(in.retain());
return;