Skip to content

Commit d9f1016

Browse files
Validate uncompressed packet size (#1527)
* Validate uncompressed packet size * Fix debug using incorrect value
1 parent c9aa1cc commit d9f1016

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressDecoder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public MinecraftCompressDecoder(int threshold, VelocityCompressor compressor) {
5252
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
5353
int claimedUncompressedSize = ProtocolUtils.readVarInt(in);
5454
if (claimedUncompressedSize == 0) {
55+
int actualUncompressedSize = in.readableBytes();
56+
checkFrame(actualUncompressedSize < threshold, "Actual uncompressed size %s is greater than"
57+
+ " threshold %s", actualUncompressedSize, threshold);
5558
// This message is not compressed.
5659
out.add(in.retain());
5760
return;

0 commit comments

Comments
 (0)