diff --git a/td/mtproto/SessionConnection.cpp b/td/mtproto/SessionConnection.cpp index f875b1ad4..47305b0af 100644 --- a/td/mtproto/SessionConnection.cpp +++ b/td/mtproto/SessionConnection.cpp @@ -304,8 +304,8 @@ Status SessionConnection::on_packet(const MsgInfo &info, uint64 req_msg_id, cons if (req_msg_id != 0) { callback_->on_message_result_error(req_msg_id, rpc_error.error_code_, rpc_error.error_message_.str()); } else { - LOG(WARNING) << "Receive rpc_error as update: [" << rpc_error.error_code_ << "][" << rpc_error.error_message_ - << "]"; + LOG(ERROR) << "Receive rpc_error as update: [" << rpc_error.error_code_ << "][" << rpc_error.error_message_ + << "]"; } return Status::OK(); } diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index 4b0297e9b..cb3f335df 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -39,6 +39,7 @@ #include "td/utils/Time.h" #include "td/utils/Timer.h" #include "td/utils/tl_parsers.h" +#include "td/utils/utf8.h" #include #include @@ -769,8 +770,17 @@ Status Session::on_message_result_ok(uint64 id, BufferSlice packet, size_t origi } void Session::on_message_result_error(uint64 id, int error_code, string message) { + if (!check_utf8(message)) { + LOG(ERROR) << "Receive invalid error message \"" << message << '"'; + message = "INVALID_UTF8_ERROR_MESSAGE"; + } + if (error_code <= -10000 || error_code >= 10000 || error_code == 0) { + LOG(ERROR) << "Receive invalid error code " << error_code << " with message \"" << message << '"'; + error_code = 500; + } + // UNAUTHORIZED - if (error_code == 401 && message != CSlice("SESSION_PASSWORD_NEEDED")) { + if (error_code == 401 && message != "SESSION_PASSWORD_NEEDED") { if (auth_data_.use_pfs() && message == CSlice("AUTH_KEY_PERM_EMPTY")) { LOG(INFO) << "Receive AUTH_KEY_PERM_EMPTY in session " << auth_data_.get_session_id() << " for auth key " << auth_data_.get_tmp_auth_key().id(); @@ -778,7 +788,7 @@ void Session::on_message_result_error(uint64 id, int error_code, string message) on_tmp_auth_key_updated(); error_code = 500; } else { - if (message == CSlice("USER_DEACTIVATED_BAN")) { + if (message == "USER_DEACTIVATED_BAN") { LOG(PLAIN) << "Your account was suspended for suspicious activity. If you think that this is a mistake, please " "write to recover@telegram.org your phone number and other details to recover the account."; }