From e8fe12b4fd5e7ca4b384e996ddf8c4c44d0bbefc Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:26:40 +0100 Subject: [PATCH] Engine: fix heap buffer overflow Should always leave 1 byte for the null terminator in the persona name buffer. --- src/engine/client/clientstate.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/engine/client/clientstate.cpp b/src/engine/client/clientstate.cpp index b328de96..7a4a5a9d 100644 --- a/src/engine/client/clientstate.cpp +++ b/src/engine/client/clientstate.cpp @@ -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) {