Increase maximum accepted reassembled packet size to 1MB, but continue to constrain directly received packet size at 65KB

This commit is contained in:
Manevolent
2019-12-04 22:01:29 -07:00
parent 475af91eef
commit 3a137f63c5
3 changed files with 4 additions and 4 deletions
@@ -92,7 +92,7 @@ public class PacketReassembly {
reassemblyBuffer.position(0);
if (firstPacket.getHeader().getPacketFlag(HeaderFlag.COMPRESSED))
reassemblyBuffer = ByteBuffer.wrap(QuickLZ.decompress(reassemblyBuffer.array()));
reassemblyBuffer = ByteBuffer.wrap(QuickLZ.decompress(reassemblyBuffer.array(), 1024 * 1024));
reassembledPacket.readBody(reassemblyBuffer);
@@ -584,7 +584,7 @@ public abstract class AbstractTeamspeakClientSocket
if (packet.getBody() instanceof PacketBodyCompressed) {
Ts3Debugging.debug("[PROTOCOL] DECOMPRESS " + networkPacket.getHeader().getType().name());
byte[] decompressed = QuickLZ.decompress(((PacketBodyCompressed) packet.getBody()).getCompressed());
byte[] decompressed = QuickLZ.decompress(((PacketBodyCompressed) packet.getBody()).getCompressed(), 65535);
packetBuffer = ByteBuffer
.wrap(decompressed)
@@ -310,7 +310,7 @@ public final class QuickLZ
a[i + j] = (byte)(value >>> (j * 8));
}
static public byte[] decompress(byte[] source) throws IOException {
static public byte[] decompress(byte[] source, int maximum) throws IOException {
try {
int level = (source[0] >>> 2) & 0x3;
@@ -318,7 +318,7 @@ public final class QuickLZ
throw new IllegalArgumentException("unsupported QuickLZ level: " + level);
int size = (int) sizeDecompressed(source);
if (size > 65536)
if (size > maximum)
throw new IllegalArgumentException("decompression too large: " + size);
int src = headerLen(source);