Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. void WorldSession::ReadAddonsInfo(ByteBuffer &data)
  2. {
  3. if (data.rpos() + 4 > data.size())
  4. return;
  5.  
  6. uint32 size;
  7. data >> size;
  8.  
  9. if (!size)
  10. return;
  11.  
  12. if (size > 0xFFFFF)
  13. {
  14. TC_LOG_DEBUG("addon", "WorldSession::ReadAddonsInfo: AddOnInfo too big, size %u", size);
  15. return;
  16. }
  17.  
  18. uLongf uSize = size;
  19.  
  20. uint32 pos = data.rpos();
  21.  
  22. ByteBuffer addonInfo;
  23. addonInfo.resize(size);
  24.  
  25. if (uncompress(addonInfo.contents(), &uSize, data.contents() + pos, data.size() - pos) == Z_OK)
  26. {
  27. for (uint32 i = 0; i < addonsCount; ++i)
  28. try
  29. {
  30. uint32 addonsCount = addonInfo.read<uint32>();
  31. if (addonsCount > Addons::MaxSecureAddons)
  32. addonsCount = Addons::MaxSecureAddons;
  33.  
  34. _addons.SecureAddons.resize(addonsCount);
  35.  
  36. for (uint32 i = 0; i < addonsCount; ++i)
  37. {
  38. Addons::SecureAddonInfo& addon = _addons.SecureAddons[i];
  39. uint32 publicKeyCrc, urlCrc;
  40.  
  41. addonInfo >> addon.Name >> addon.HasKey;
  42. addonInfo >> publicKeyCrc >> urlCrc;
  43. 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);
  44.  
  45. SavedAddon const* savedAddon = AddonMgr::GetAddonInfo(addon.Name);
  46. if (savedAddon)
  47. {
  48. if (publicKeyCrc != savedAddon->CRC)
  49. {
  50. if (addon.HasKey)
  51. {
  52. addon.Status = Addons::SecureAddonInfo::BANNED;
  53. TC_LOG_WARN("addon", " Addon: %s: modified (CRC: 0x%x) - accountID %d)", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
  54. }
  55. else
  56. addon.Status = Addons::SecureAddonInfo::SECURE_HIDDEN;
  57. }
  58. else
  59. {
  60. addon.Status = Addons::SecureAddonInfo::SECURE_HIDDEN;
  61. TC_LOG_DEBUG("addon", "Addon: %s: validated (CRC: 0x%x) - accountID %d", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
  62. }
  63. }
  64. else
  65. {
  66. addon.Status = Addons::SecureAddonInfo::BANNED;
  67. TC_LOG_WARN("addon", "Addon: %s: not registered as known secure addon - accountId %d", addon.Name.c_str(), GetAccountId());
  68. }
  69. }
  70.  
  71. addonInfo.rpos(addonInfo.size() - 4);
  72.  
  73. uint32 lastBannedAddOnTimestamp;
  74. addonInfo >> lastBannedAddOnTimestamp;
  75. TC_LOG_DEBUG("addon", "AddOn: Newest banned addon timestamp: %u", lastBannedAddOnTimestamp);
  76. }
  77. catch (ByteBufferException const& e)
  78. {
  79. TC_LOG_DEBUG("addon", "AddOn: Addon packet read error! %s", e.what());
  80. }
  81. }
  82. else
  83. TC_LOG_DEBUG("addon", "AddOn: Addon packet uncompress error!");
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement