Browse Source

client: MOTD: Prevent out of bounds access on x86.

sentencewarn
Andrey Akhmichin 1 year ago
parent
commit
dd6995ecbd
  1. 12
      cl_dll/MOTD.cpp

12
cl_dll/MOTD.cpp

@ -73,7 +73,7 @@ int CHudMOTD::Draw( float fTime )
//bool bScroll; //bool bScroll;
// find the top of where the MOTD should be drawn, so the whole thing is centered in the screen // 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 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; int xpos = ( ScreenWidth - gHUD.m_scrinfo.charWidths['M'] * m_iMaxLength ) / 2;
if( xpos < 30 ) if( xpos < 30 )
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 ); gHUD.DrawDarkRectangle( xpos - 5, ypos_r - 5, xmax - xpos + 10, height + 10 );
while( *ch ) while( *ch )
{ {
char *next_line; unsigned char *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++ ) 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' ) if( *top == '\n' )
*top = 0; *top = 0;
else else

Loading…
Cancel
Save