From 1554044a84bb5b70a2c31fb3079b11a63753b591 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 2 Jun 2021 01:50:00 +0300 Subject: [PATCH] Simplify removing packet padding. --- td/mtproto/Transport.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/td/mtproto/Transport.cpp b/td/mtproto/Transport.cpp index 9d90e18a0..9498ea00d 100644 --- a/td/mtproto/Transport.cpp +++ b/td/mtproto/Transport.cpp @@ -227,11 +227,7 @@ Status Transport::read_crypto_impl(int X, MutableSlice message, const AuthKey &a auto *header = reinterpret_cast(message.begin()); *header_ptr = header; auto to_decrypt = MutableSlice(header->encrypt_begin(), message.uend()); - to_decrypt.truncate(to_decrypt.size() & ~15); - if (to_decrypt.size() % 16 != 0) { - return Status::Error(PSLICE() << "Invalid mtproto message: size of encrypted part is not multiple of 16 [size = " - << to_decrypt.size() << "]"); - } + to_decrypt.remove_suffix(to_decrypt.size() & 15); if (header->auth_key_id != auth_key.id()) { return Status::Error(PSLICE() << "Invalid mtproto message: auth_key_id mismatch [found = "