Engine: fix heap buffer overflow

Should always leave 1 byte for the null terminator in the persona name buffer.
This commit is contained in:
Kawe Mazidjatari 2024-11-14 15:26:40 +01:00
parent da6ffe9005
commit e8fe12b4fd

View File

@ -43,12 +43,11 @@ static void SetName_f(const CCommand& args)
const size_t nLen = strlen(pszName);
if (nLen > MAX_PERSONA_NAME_LEN)
if (nLen >= MAX_PERSONA_NAME_LEN)
return;
// Update nucleus name.
memset(g_PersonaName, '\0', MAX_PERSONA_NAME_LEN);
strncpy(g_PersonaName, pszName, nLen);
strncpy(g_PersonaName, pszName, nLen+1);
}
static void Reconnect_f(const CCommand& args)
{