clear input buffer in case of bad varints

This commit is contained in:
Andrew Steinborn
2021-03-30 12:05:43 -04:00
parent 0cc300b621
commit 8aad6e2ece

View File

@@ -34,6 +34,7 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
int readVarint = reader.getReadVarint();
int bytesRead = reader.getBytesRead();
if (readVarint < 0) {
in.clear();
throw BAD_LENGTH_CACHED;
} else if (readVarint == 0) {
// skip over the empty packet and ignore it
@@ -46,6 +47,7 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
}
}
} else if (reader.getResult() == DecodeResult.TOO_BIG) {
in.clear();
throw VARINT_BIG_CACHED;
}
}