Skip to content

Commit

Permalink
client: MOTD: Prevent out of bounds access on x86.
Browse files Browse the repository at this point in the history
  • Loading branch information
nekonomicon committed Oct 31, 2023
1 parent 2218731 commit dd6995e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cl_dll/MOTD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit dd6995e

Please sign in to comment.