Use str_copy instead of mem_copy for skin names

The `mem_copy` function does not respect zero termination so it reads beyond the size of the source buffer, if it's smaller than the destination buffer.
This commit is contained in:
Robert Müller 2023-12-22 22:13:17 +01:00
parent 32b32d7052
commit fa0b218eed

View file

@ -418,7 +418,7 @@ void CMenus::RandomSkin()
unsigned *pColorBody = !m_Dummy ? &g_Config.m_ClPlayerColorBody : &g_Config.m_ClDummyColorBody;
unsigned *pColorFeet = !m_Dummy ? &g_Config.m_ClPlayerColorFeet : &g_Config.m_ClDummyColorFeet;
mem_copy(pSkinName, pRandomSkinName, sizeof(g_Config.m_ClPlayerSkin));
str_copy(pSkinName, pRandomSkinName, sizeof(g_Config.m_ClPlayerSkin));
*pColorBody = Body.Pack(false);
*pColorFeet = Feet.Pack(false);
@ -862,7 +862,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
const int NewSelected = s_ListBox.DoEnd();
if(OldSelected != NewSelected)
{
mem_copy(pSkinName, s_vSkinList[NewSelected].m_pSkin->GetName(), sizeof(g_Config.m_ClPlayerSkin));
str_copy(pSkinName, s_vSkinList[NewSelected].m_pSkin->GetName(), sizeof(g_Config.m_ClPlayerSkin));
SetNeedSendInfo();
}