Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void WorldSession::ReadAddonsInfo(ByteBuffer &data)
- {
- if (data.rpos() + 4 > data.size())
- return;
- uint32 size;
- data >> size;
- if (!size)
- return;
- if (size > 0xFFFFF)
- {
- TC_LOG_DEBUG("addon", "WorldSession::ReadAddonsInfo: AddOnInfo too big, size %u", size);
- return;
- }
- uLongf uSize = size;
- uint32 pos = data.rpos();
- ByteBuffer addonInfo;
- addonInfo.resize(size);
- if (uncompress(addonInfo.contents(), &uSize, data.contents() + pos, data.size() - pos) == Z_OK)
- {
- for (uint32 i = 0; i < addonsCount; ++i)
- try
- {
- uint32 addonsCount = addonInfo.read<uint32>();
- if (addonsCount > Addons::MaxSecureAddons)
- addonsCount = Addons::MaxSecureAddons;
- _addons.SecureAddons.resize(addonsCount);
- for (uint32 i = 0; i < addonsCount; ++i)
- {
- Addons::SecureAddonInfo& addon = _addons.SecureAddons[i];
- uint32 publicKeyCrc, urlCrc;
- addonInfo >> addon.Name >> addon.HasKey;
- addonInfo >> publicKeyCrc >> urlCrc;
- TC_LOG_DEBUG("addon", "AddOn: %s (CRC: 0x%x) - has key: 0x%x - URL CRC: 0x%x", addon.Name.c_str(), publicKeyCrc, addon.HasKey, urlCrc);
- SavedAddon const* savedAddon = AddonMgr::GetAddonInfo(addon.Name);
- if (savedAddon)
- {
- if (publicKeyCrc != savedAddon->CRC)
- {
- if (addon.HasKey)
- {
- addon.Status = Addons::SecureAddonInfo::BANNED;
- TC_LOG_WARN("addon", " Addon: %s: modified (CRC: 0x%x) - accountID %d)", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
- }
- else
- addon.Status = Addons::SecureAddonInfo::SECURE_HIDDEN;
- }
- else
- {
- addon.Status = Addons::SecureAddonInfo::SECURE_HIDDEN;
- TC_LOG_DEBUG("addon", "Addon: %s: validated (CRC: 0x%x) - accountID %d", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
- }
- }
- else
- {
- addon.Status = Addons::SecureAddonInfo::BANNED;
- TC_LOG_WARN("addon", "Addon: %s: not registered as known secure addon - accountId %d", addon.Name.c_str(), GetAccountId());
- }
- }
- addonInfo.rpos(addonInfo.size() - 4);
- uint32 lastBannedAddOnTimestamp;
- addonInfo >> lastBannedAddOnTimestamp;
- TC_LOG_DEBUG("addon", "AddOn: Newest banned addon timestamp: %u", lastBannedAddOnTimestamp);
- }
- catch (ByteBufferException const& e)
- {
- TC_LOG_DEBUG("addon", "AddOn: Addon packet read error! %s", e.what());
- }
- }
- else
- TC_LOG_DEBUG("addon", "AddOn: Addon packet uncompress error!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement