From 6af5c3f472f1efc6c65369689499b3431ce0650b Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Wed, 1 Apr 2020 13:14:14 +0500 Subject: [PATCH] Safe _snprintf usage. --- cl_dll/text_message.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index 512623dd..daeacf3f 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -182,19 +182,23 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf { case HUD_PRINTCENTER: _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + psz[MSG_BUF_SIZE - 1] = '\0'; CenterPrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTNOTIFY: psz[0] = 1; // mark this message to go into the notify buffer _snprintf( psz + 1, MSG_BUF_SIZE - 1, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + psz[MSG_BUF_SIZE - 2] = '\0'; ConsolePrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTTALK: _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + psz[MSG_BUF_SIZE - 1] = '\0'; gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), MSG_BUF_SIZE ); break; case HUD_PRINTCONSOLE: _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + psz[MSG_BUF_SIZE - 1] = '\0'; ConsolePrint( ConvertCRtoNL( psz ) ); break; }