mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Misc: Fixed array out of bounds access when loading locales_achievement_reward, locales_creature_text, locales_gossip_menu_option and skip LOCALE_none when iterating over locales
This commit is contained in:
@@ -3342,7 +3342,7 @@ void AchievementGlobalMgr::LoadRewardLocales()
|
||||
|
||||
AchievementRewardLocale& data = _achievementRewardLocales[entry];
|
||||
|
||||
for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i)
|
||||
for (uint8 i = OLD_TOTAL_LOCALES - 1; i > 0; --i)
|
||||
{
|
||||
LocaleConstant locale = (LocaleConstant) i;
|
||||
ObjectMgr::AddLocaleString(fields[1 + 2 * (i - 1)].GetString(), locale, data.subject);
|
||||
|
||||
@@ -230,6 +230,9 @@ bool ItemChatLink::ValidateName(char* buffer, const char* context)
|
||||
{
|
||||
for (uint8 index = LOCALE_koKR; index < TOTAL_LOCALES; ++index)
|
||||
{
|
||||
if (index == LOCALE_none)
|
||||
continue;
|
||||
|
||||
if (FormatName(index, suffixStrings) == buffer)
|
||||
{
|
||||
res = true;
|
||||
@@ -412,8 +415,13 @@ bool AchievementChatLink::ValidateName(char* buffer, const char* context)
|
||||
ChatLink::ValidateName(buffer, context);
|
||||
|
||||
for (uint8 locale = LOCALE_enUS; locale < TOTAL_LOCALES; ++locale)
|
||||
{
|
||||
if (locale == LOCALE_none)
|
||||
continue;
|
||||
|
||||
if (strcmp(_achievement->Title->Str[locale], buffer) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): linked achievement (id: %u) name wasn't found in any localization", context, _achievement->ID);
|
||||
return false;
|
||||
|
||||
@@ -158,7 +158,7 @@ inline void LoadDB2(uint32& availableDb2Locales, DB2StoreProblemList& errlist, D
|
||||
|
||||
for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
|
||||
{
|
||||
if (defaultLocale == i)
|
||||
if (defaultLocale == i || i == LOCALE_none)
|
||||
continue;
|
||||
|
||||
if (availableDb2Locales & (1 << i))
|
||||
@@ -380,8 +380,15 @@ void DB2Manager::LoadStores(std::string const& dataPath, uint32 defaultLocale)
|
||||
if (namesProfanity->Language != -1)
|
||||
_nameValidators[namesProfanity->Language].emplace_back(namesProfanity->Name, boost::regex::perl | boost::regex::icase | boost::regex::optimize);
|
||||
else
|
||||
{
|
||||
for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
|
||||
{
|
||||
if (i == LOCALE_none)
|
||||
continue;
|
||||
|
||||
_nameValidators[i].emplace_back(namesProfanity->Name, boost::regex::perl | boost::regex::icase | boost::regex::optimize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (NamesReservedEntry const* namesReserved : sNamesReservedStore)
|
||||
@@ -391,8 +398,13 @@ void DB2Manager::LoadStores(std::string const& dataPath, uint32 defaultLocale)
|
||||
{
|
||||
ASSERT(!(namesReserved->LocaleMask & ~((1 << TOTAL_LOCALES) - 1)));
|
||||
for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
|
||||
{
|
||||
if (i == LOCALE_none)
|
||||
continue;
|
||||
|
||||
if (namesReserved->LocaleMask & (1 << i))
|
||||
_nameValidators[i].emplace_back(namesReserved->Name, boost::regex::perl | boost::regex::icase | boost::regex::optimize);
|
||||
}
|
||||
}
|
||||
|
||||
for (PhaseXPhaseGroupEntry const* group : sPhaseXPhaseGroupStore)
|
||||
|
||||
@@ -203,7 +203,7 @@ inline void LoadDBC(uint32& availableDbcLocales, StoreProblemList& errors, DBCSt
|
||||
{
|
||||
for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
|
||||
{
|
||||
if (!(availableDbcLocales & (1 << i)))
|
||||
if (i == LOCALE_none || !(availableDbcLocales & (1 << i)))
|
||||
continue;
|
||||
|
||||
std::string localizedName(dbcPath);
|
||||
@@ -256,7 +256,7 @@ inline void LoadGameTable(StoreProblemList& errors, std::string const& tableName
|
||||
|
||||
for (uint32 l = 0; l < TOTAL_LOCALES; ++l)
|
||||
{
|
||||
if (tableName == gt->Name->Str[l])
|
||||
if (i != LOCALE_none && tableName == gt->Name->Str[l])
|
||||
{
|
||||
found = true;
|
||||
storage.SetGameTableEntry(gt);
|
||||
|
||||
@@ -185,7 +185,7 @@ void CreatureTextMgr::LoadCreatureTextLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
CreatureTextLocale& loc = mLocaleTextMap[CreatureTextId(fields[0].GetUInt32(), uint32(fields[1].GetUInt8()), uint32(fields[2].GetUInt8()))];
|
||||
for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i)
|
||||
for (uint8 i = OLD_TOTAL_LOCALES - 1; i > 0; --i)
|
||||
{
|
||||
LocaleConstant locale = LocaleConstant(i);
|
||||
ObjectMgr::AddLocaleString(fields[3 + i - 1].GetString(), locale, loc.Text);
|
||||
|
||||
Reference in New Issue
Block a user