Fix settings compare

It was just using a heuristic, comparing the first 24 bytes. Memory unsafety
for configs that were shorter than 24 bytes.
This commit is contained in:
heinrich5991 2015-08-27 16:20:56 +02:00
parent a32aca50bf
commit 3a069093d7
2 changed files with 2 additions and 2 deletions

View file

@ -2594,7 +2594,7 @@ void CGameContext::OnMapChange(char *pNewMapName, int MapNameSize)
SettingsIndex = pInfo->m_Settings;
char *pMapSettings = (char *)Reader.GetData(SettingsIndex);
int DataSize = Reader.GetUncompressedDataSize(SettingsIndex);
if(DataSize == TotalLength && mem_comp(pSettings, pMapSettings, Size) == 0)
if(DataSize == TotalLength && mem_comp(pSettings, pMapSettings, DataSize) == 0)
{
// Configs coincide, no need to update map.
return;

View file

@ -70,7 +70,7 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
SettingsIndex = pInfo->m_Settings;
char *pMapSettings = (char *)Reader.GetData(SettingsIndex);
int DataSize = Reader.GetUncompressedDataSize(SettingsIndex);
if(DataSize == TotalLength && mem_comp(pSettings, pMapSettings, Size) == 0)
if(DataSize == TotalLength && mem_comp(pSettings, pMapSettings, DataSize) == 0)
{
dbg_msg("config_store", "configs coincide, not updating map");
return;