3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Handle partially sent varints better

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-05-29 21:11:21 -04:00
Ursprung b6f1dcc166
Commit dd2e1ad241

Datei anzeigen

@ -20,18 +20,26 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
return; return;
} }
if (!reader.successfulDecode) { if (reader.successfulDecode) {
throw BAD_LENGTH_CACHED; if (reader.readVarint < 0) {
} throw BAD_LENGTH_CACHED;
}
int minimumRead = reader.bytesRead + reader.readVarint; int minimumRead = reader.bytesRead + reader.readVarint;
if (in.isReadable(minimumRead)) { if (in.isReadable(minimumRead)) {
out.add(in.retainedSlice(varintEnd + 1, reader.readVarint)); out.add(in.retainedSlice(varintEnd + 1, reader.readVarint));
in.skipBytes(minimumRead); in.skipBytes(minimumRead);
reader.reset(); reader.reset();
} else {
reader.reset();
return;
}
} else { } else {
boolean tooBig = reader.bytesRead > 3;
reader.reset(); reader.reset();
return; if (tooBig) {
throw BAD_LENGTH_CACHED;
}
} }
} }
} }