Add more DcId checks.
GitOrigin-RevId: ca4bfdc046e78ef7e216c8a5bda8e5ddcd88cfec
This commit is contained in:
parent
37359e9898
commit
fe9f1e52d2
@ -449,9 +449,14 @@ StringBuilder &operator<<(StringBuilder &string_builder, const PhotoSize &photo_
|
||||
|
||||
Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::encryptedFile> &&file,
|
||||
tl_object_ptr<secret_api::decryptedMessageMediaPhoto> &&photo, DialogId owner_dialog_id) {
|
||||
CHECK(DcId::is_valid(file->dc_id_));
|
||||
DcId dc_id;
|
||||
if (!DcId::is_valid(file->dc_id_)) {
|
||||
dc_id = DcId::invalid();
|
||||
} else {
|
||||
dc_id = DcId::internal(file->dc_id_);
|
||||
}
|
||||
FileId file_id = file_manager->register_remote(
|
||||
FullRemoteFileLocation(FileType::Encrypted, file->id_, file->access_hash_, DcId::internal(file->dc_id_), ""),
|
||||
FullRemoteFileLocation(FileType::Encrypted, file->id_, file->access_hash_, dc_id, ""),
|
||||
FileLocationSource::FromServer, owner_dialog_id, photo->size_, 0,
|
||||
PSTRING() << static_cast<uint64>(file->id_) << ".jpg");
|
||||
file_manager->set_encryption_key(file_id, FileEncryptionKey{photo->key_.as_slice(), photo->iv_.as_slice()});
|
||||
|
@ -134,6 +134,9 @@ Status FileHashUploader::on_result_impl(NetQueryPtr net_query) {
|
||||
return Status::Error("Document is not found by hash");
|
||||
case telegram_api::document::ID: {
|
||||
auto document = move_tl_object_as<telegram_api::document>(res);
|
||||
if (!DcId::is_valid(document->dc_id_)) {
|
||||
return Status::Error("Found document has invalid DcId");
|
||||
}
|
||||
callback_->on_ok(FullRemoteFileLocation(FileType::Document, document->id_, document->access_hash_,
|
||||
DcId::internal(document->dc_id_),
|
||||
document->file_reference_.as_slice().str()));
|
||||
|
@ -31,7 +31,12 @@ DcAuthManager::DcAuthManager(ActorShared<> parent) {
|
||||
parent_ = std::move(parent);
|
||||
auto s_main_dc_id = G()->td_db()->get_binlog_pmc()->get("main_dc_id");
|
||||
if (!s_main_dc_id.empty()) {
|
||||
main_dc_id_ = DcId::internal(to_integer<int32>(s_main_dc_id));
|
||||
auto main_dc_id = to_integer<int32>(s_main_dc_id);
|
||||
if (DcId::is_valid(main_dc_id)) {
|
||||
main_dc_id_ = DcId::internal(main_dc_id);
|
||||
} else {
|
||||
LOG(ERROR) << "Receive invalid main dc id " << main_dc_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,10 +148,15 @@ class DcOption {
|
||||
void parse(ParserT &parser) {
|
||||
flags_ = parser.fetch_int();
|
||||
auto raw_dc_id = parser.fetch_int();
|
||||
if ((flags_ & Flags::Cdn) != 0) {
|
||||
dc_id_ = DcId::external(raw_dc_id);
|
||||
if (!DcId::is_valid(raw_dc_id)) {
|
||||
LOG(ERROR) << "Have invalid DC ID " << raw_dc_id;
|
||||
dc_id_ = DcId::invalid();
|
||||
} else {
|
||||
dc_id_ = DcId::internal(raw_dc_id);
|
||||
if ((flags_ & Flags::Cdn) != 0) {
|
||||
dc_id_ = DcId::external(raw_dc_id);
|
||||
} else {
|
||||
dc_id_ = DcId::internal(raw_dc_id);
|
||||
}
|
||||
}
|
||||
auto ip = parser.template fetch_string<std::string>();
|
||||
auto port = parser.fetch_int();
|
||||
|
Reference in New Issue
Block a user