Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Revert this entirely for now.
Dieser Commit ist enthalten in:
Ursprung
8dea7567d8
Commit
9b570ff599
@ -11,35 +11,36 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
int lastReaderIndex = in.readerIndex();
|
if (!in.isReadable()) {
|
||||||
find_packets: while (in.isReadable()) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int origReaderIndex = in.readerIndex();
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (!in.isReadable()) {
|
if (!in.isReadable()) {
|
||||||
break;
|
in.readerIndex(origReaderIndex);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte read = in.readByte();
|
byte read = in.readByte();
|
||||||
if (read >= 0) {
|
if (read >= 0) {
|
||||||
// Make sure reader index of length buffer is returned to the beginning
|
// Make sure reader index of length buffer is returned to the beginning
|
||||||
in.readerIndex(lastReaderIndex);
|
in.readerIndex(origReaderIndex);
|
||||||
int packetLength = ProtocolUtils.readVarInt(in);
|
int packetLength = ProtocolUtils.readVarInt(in);
|
||||||
if (packetLength == 0) {
|
if (packetLength == 0) {
|
||||||
continue find_packets;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in.readableBytes() < packetLength) {
|
if (in.readableBytes() < packetLength) {
|
||||||
break find_packets;
|
in.readerIndex(origReaderIndex);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.add(in.readRetainedSlice(packetLength));
|
out.add(in.readRetainedSlice(packetLength));
|
||||||
lastReaderIndex = in.readerIndex();
|
return;
|
||||||
continue find_packets;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new CorruptedFrameException("VarInt too big");
|
throw new CorruptedFrameException("VarInt too big");
|
||||||
}
|
}
|
||||||
|
|
||||||
in.readerIndex(lastReaderIndex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren