mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-28 04:13:45 +03:00
Improve unhelpful 'readexactly size can not be less than zero'
Technically closes #4092, as the error is now properly handled.
This commit is contained in:
parent
9aad453e1a
commit
03ff996ace
|
@ -30,6 +30,11 @@ class FullPacketCodec(PacketCodec):
|
|||
# See https://github.com/LonamiWebs/Telethon/issues/4042.
|
||||
body = await reader.readexactly(4)
|
||||
raise InvalidBufferError(body)
|
||||
elif packet_len < 8:
|
||||
# Currently unknown why packet_len may be less than 8 but not negative.
|
||||
# Attempting to `readexactly` with less than 0 fails without saying what
|
||||
# the number was which is less helpful.
|
||||
raise InvalidBufferError(packet_len_seq)
|
||||
|
||||
body = await reader.readexactly(packet_len - 8)
|
||||
checksum = struct.unpack('<I', body[-4:])[0]
|
||||
|
|
Loading…
Reference in New Issue
Block a user