From 8aad6e2ece5e7541b0bad23acc1fad7bf145436a Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 30 Mar 2021 12:05:43 -0400 Subject: [PATCH] clear input buffer in case of bad varints --- .../proxy/protocol/netty/MinecraftVarintFrameDecoder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java index 6ffeaa44f..f125faae6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java @@ -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; } }