mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-11-16 13:43:08 +00:00
Remove critical code from assert statements
This commit is contained in:
@@ -163,7 +163,9 @@ async def do_authentication(sender):
|
||||
if dh_hash != new_nonce_hash:
|
||||
raise SecurityError('Step 3 invalid new nonce hash')
|
||||
|
||||
assert isinstance(dh_gen, DhGenOk), 'Step 3.2 answer was %s' % dh_gen
|
||||
if not isinstance(dh_gen, DhGenOk):
|
||||
raise AssertionError('Step 3.2 answer was %s' % dh_gen)
|
||||
|
||||
return auth_key, time_offset
|
||||
|
||||
|
||||
|
||||
@@ -39,15 +39,18 @@ class MTProtoPlainSender:
|
||||
raise BrokenAuthKeyError()
|
||||
|
||||
with BinaryReader(body) as reader:
|
||||
assert reader.read_long() == 0, 'Bad auth_key_id' # auth_key_id
|
||||
auth_key_id = reader.read_long()
|
||||
assert auth_key_id == 0, 'Bad auth_key_id'
|
||||
|
||||
assert reader.read_long() != 0, 'Bad msg_id' # msg_id
|
||||
msg_id = reader.read_long()
|
||||
assert msg_id != 0, 'Bad msg_id'
|
||||
# ^ We should make sure that the read ``msg_id`` is greater
|
||||
# than our own ``msg_id``. However, under some circumstances
|
||||
# (bad system clock/working behind proxies) this seems to not
|
||||
# be the case, which would cause endless assertion errors.
|
||||
|
||||
assert reader.read_int() > 0, 'Bad length' # length
|
||||
length = reader.read_int()
|
||||
assert length > 0, 'Bad length'
|
||||
# We could read length bytes and use those in a new reader to read
|
||||
# the next TLObject without including the padding, but since the
|
||||
# reader isn't used for anything else after this, it's unnecessary.
|
||||
|
||||
Reference in New Issue
Block a user