When a packet with an invalid ID is received, an IndexOutOfBoundsException occurs instead of a "Bad packet id" message. For instance, instead of "Internal Exception: io.netty.handler.codec.DecoderException: java.io.IOException: Bad packet id 42", the message is "Internal Exception: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: Index 42, Size: 5". When combined with MC-134498, it is very difficult to tell whether the issue is with the implementation of the packet or with something else. This is only really an issue for people implementing custom servers; it shouldn't affect regular gameplay (apart from randomly corrupt packets, in which case the exact error message doesn't really matter).
The following Python code should replicate the issue:
import socket
import time
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.bind(('', 1234))
serversocket.listen(1)
(clientsocket, address) = serversocket.accept()
time.sleep(1)
clientsocket.sendall(bytes([1, 42])) # Invalid packet, length 1, packet ID 42, no further payload
time.sleep(1)
clientsocket.close()
serversocket.close()
Test by connecting to localhost:1234
; in current versions, this will result in an IndexOutOfBoundsException.
An example stacktrace from 1.16.5 in the wild: https://pastebin.com/a5FFYicS
This issue was first introduced in 19w34a (the first 1.15 snapshot); it did not occur in 1.14.4. This version created ConnectionProtocol$PacketSet
; the idToConstructor
field is not bounds-checked in createPacket
, so an exception is thrown instead of returning null
(prior versions used an Object2IntMap
, which would have returned null
). Note also that the code that creates the Bad packet id
message still exists and should still run if the bounds-check is re-added.
Linked issues
relates to 1
Comments 0
No comments.