diff --git a/src/main/java/me/steinborn/krypton/mod/shared/network/VarintByteDecoder.java b/src/main/java/me/steinborn/krypton/mod/shared/network/VarintByteDecoder.java index 24100d5..ff4cc78 100644 --- a/src/main/java/me/steinborn/krypton/mod/shared/network/VarintByteDecoder.java +++ b/src/main/java/me/steinborn/krypton/mod/shared/network/VarintByteDecoder.java @@ -3,6 +3,10 @@ import io.netty.util.ByteProcessor; public class VarintByteDecoder implements ByteProcessor { + + private static final int MAXIMUM_VARINT_BYTE_SIZE = Boolean.getBoolean("krypton.permit-oversized-packets") + ? 5 : 3; + private int readVarint; private int bytesRead; private DecodeResult result = DecodeResult.TOO_SHORT; @@ -18,7 +22,7 @@ public boolean process(byte k) { return false; } readVarint |= (k & 0x7F) << bytesRead++ * 7; - if (bytesRead > 3) { + if (bytesRead > MAXIMUM_VARINT_BYTE_SIZE) { result = DecodeResult.TOO_BIG; return false; } diff --git a/src/main/java/me/steinborn/krypton/mod/shared/network/compression/MinecraftCompressDecoder.java b/src/main/java/me/steinborn/krypton/mod/shared/network/compression/MinecraftCompressDecoder.java index 5b45457..109f4cd 100644 --- a/src/main/java/me/steinborn/krypton/mod/shared/network/compression/MinecraftCompressDecoder.java +++ b/src/main/java/me/steinborn/krypton/mod/shared/network/compression/MinecraftCompressDecoder.java @@ -12,7 +12,8 @@ public class MinecraftCompressDecoder extends ByteToMessageDecoder { - private static final int UNCOMPRESSED_CAP = 8 * 1024 * 1024; // 8MiB + private static final int UNCOMPRESSED_CAP = Boolean.getBoolean("krypton.permit-oversized-packets") + ? Integer.MAX_VALUE : 8 * 1024 * 1024; private int threshold; private final boolean validate;