ProtocolLib

3M Downloads

Netty Exception on kick during handshaking

paulzhng opened this issue ยท 0 comments

commented

Describe the bug
Netty Exception when kicking the player / directly closing the channel of the network manager during Handshake.

[15:45:34 WARN]: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(1) + length(1) exceeds writerIndex(1): PooledUnsafeDirectByteBuf(ridx: 1, widx: 1, cap: 1)
[15:45:34 WARN]:        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:459)
[15:45:34 WARN]:        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
[15:45:34 WARN]:        at com.comphenix.protocol.injector.netty.ChannelInjector$2.channelRead(ChannelInjector.java:259)[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
[15:45:34 WARN]:        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
[15:45:34 WARN]:        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
[15:45:34 WARN]:        at net.minecraft.server.v1_12_R1.LegacyPingHandler.channelRead(LegacyPingHandler.java:121)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
[15:45:34 WARN]:        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
[15:45:34 WARN]:        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[15:45:34 WARN]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[15:45:34 WARN]:        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)
[15:45:34 WARN]:        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
[15:45:34 WARN]:        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
[15:45:34 WARN]:        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
[15:45:34 WARN]:        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
[15:45:34 WARN]:        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
[15:45:34 WARN]:        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
[15:45:34 WARN]:        at java.lang.Thread.run(Unknown Source)
[15:45:34 WARN]: Caused by: java.lang.IndexOutOfBoundsException: readerIndex(1) + length(1) exceeds writerIndex(1): PooledUnsafeDirectByteBuf(ridx: 1, widx: 1, cap: 1)
[15:45:34 WARN]:        at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1405)
[15:45:34 WARN]:        at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:707)
[15:45:34 WARN]:        at net.minecraft.server.v1_12_R1.PacketDataSerializer.readByte(PacketDataSerializer.java:676)
[15:45:34 WARN]:        at net.minecraft.server.v1_12_R1.PacketDataSerializer.g(PacketDataSerializer.java:150)
[15:45:34 WARN]:        at net.minecraft.server.v1_12_R1.PacketHandshakingInSetProtocol.a(PacketHandshakingInSetProtocol.java:15)
[15:45:34 WARN]:        at net.minecraft.server.v1_12_R1.PacketDecoder.decode(SourceFile:40)
[15:45:34 WARN]:        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[15:45:34 WARN]:        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[15:45:34 WARN]:        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[15:45:34 WARN]:        at java.lang.reflect.Method.invoke(Unknown Source)
[15:45:34 WARN]:        at com.comphenix.protocol.injector.netty.ChannelInjector.decode(ChannelInjector.java:514)
[15:45:34 WARN]:        at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
[15:45:34 WARN]:        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
[15:45:34 WARN]:        ... 32 more

To Reproduce
Steps to reproduce the behavior:

  1. Hook into PacketType.Handshake.Client.SET_PROTOCOL
  2. Kick the player in that event
  3. See error

Expected behavior
No exception.

Screenshots
If applicable, add screenshots to help explain your problem.

Version Info
https://pastebin.com/PFR8zyGr

Additional context
Behavior noticed when testing TCPShield v2.0 (https://github.com/TCPShield/RealIP) and confirmed using a raw plugin.
Tested on a localhost machine. Connection is being closed properly, so only the exception in the console's a problem.

Alternative ways of solution
Provide another method to disconnect the player during that phase of connection.