mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 01:17:47 +01:00
Checking that payload length is positive on packets reading (#1211)
This commit is contained in:
parent
4884051c6a
commit
0c6599fee6
@ -172,6 +172,9 @@ public final class PacketUtils {
|
|||||||
if (compressed) {
|
if (compressed) {
|
||||||
final int dataLength = readBuffer.readVarInt();
|
final int dataLength = readBuffer.readVarInt();
|
||||||
final int payloadLength = packetLength - (readBuffer.readerOffset() - readerStart);
|
final int payloadLength = packetLength - (readBuffer.readerOffset() - readerStart);
|
||||||
|
if (payloadLength < 0) {
|
||||||
|
throw new DataFormatException("Negative payload length " + payloadLength);
|
||||||
|
}
|
||||||
if (dataLength == 0) {
|
if (dataLength == 0) {
|
||||||
// Data is too small to be compressed, payload is following
|
// Data is too small to be compressed, payload is following
|
||||||
decompressedSize = payloadLength;
|
decompressedSize = payloadLength;
|
||||||
|
Loading…
Reference in New Issue
Block a user