From dd6995ecbd80e20391ad13ea143340f22156bb97 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Wed, 1 Nov 2023 02:27:00 +0500 Subject: [PATCH] client: MOTD: Prevent out of bounds access on x86. --- cl_dll/MOTD.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cl_dll/MOTD.cpp b/cl_dll/MOTD.cpp index 1ca1c0f8..78844642 100644 --- a/cl_dll/MOTD.cpp +++ b/cl_dll/MOTD.cpp @@ -73,7 +73,7 @@ int CHudMOTD::Draw( float fTime ) //bool bScroll; // find the top of where the MOTD should be drawn, so the whole thing is centered in the screen int ypos = ( ScreenHeight - LINE_HEIGHT * m_iLines ) / 2; // shift it up slightly - char *ch = m_szMOTD; + unsigned char *ch = (unsigned char*)m_szMOTD; int xpos = ( ScreenWidth - gHUD.m_scrinfo.charWidths['M'] * m_iMaxLength ) / 2; if( xpos < 30 ) xpos = 30; @@ -95,11 +95,13 @@ int CHudMOTD::Draw( float fTime ) gHUD.DrawDarkRectangle( xpos - 5, ypos_r - 5, xmax - xpos + 10, height + 10 ); while( *ch ) { - char *next_line; - int line_length = 0; // count the length of the current line + unsigned char *next_line; for( next_line = ch; *next_line != '\n' && *next_line != 0; next_line++ ) - line_length += gHUD.m_scrinfo.charWidths[*next_line]; - char *top = next_line; + ; + // int line_length = 0; // count the length of the current line + // for( next_line = ch; *next_line != '\n' && *next_line != 0; next_line++ ) + // line_length += gHUD.m_scrinfo.charWidths[*next_line]; + unsigned char *top = next_line; if( *top == '\n' ) *top = 0; else