From cea0903626813faad91b8d7db46679fdf5efcc0c Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Mon, 14 Nov 2022 08:14:24 +0500 Subject: [PATCH] More safe strncat usage. --- cl_dll/MOTD.cpp | 3 ++- cl_dll/death.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cl_dll/MOTD.cpp b/cl_dll/MOTD.cpp index c48a9af1..1ca1c0f8 100644 --- a/cl_dll/MOTD.cpp +++ b/cl_dll/MOTD.cpp @@ -134,7 +134,8 @@ int CHudMOTD::MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf ) BEGIN_READ( pbuf, iSize ); int is_finished = READ_BYTE(); - strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) - 1 ); + strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) - strlen(m_szMOTD) - 1 ); + m_szMOTD[sizeof(m_szMOTD) - 1] = '\0'; if( is_finished ) { diff --git a/cl_dll/death.cpp b/cl_dll/death.cpp index 1dbb0b39..b4a6539c 100644 --- a/cl_dll/death.cpp +++ b/cl_dll/death.cpp @@ -173,6 +173,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu char killedwith[32]; strcpy( killedwith, "d_" ); strncat( killedwith, READ_STRING(), sizeof(killedwith) - strlen(killedwith) - 1 ); + killedwith[sizeof(killedwith) - 1] = '\0'; #if USE_VGUI if (gViewPort)