mirror of
https://github.com/ENSL/NS.git
synced 2025-01-18 23:41:51 +00:00
o Fixed the textmsg crash that could cause ill-formatted text strings to crash clients.
git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@390 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
parent
83d73162d3
commit
e653265899
1 changed files with 19 additions and 1 deletions
|
@ -162,7 +162,7 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf
|
|||
int destination;
|
||||
StringList message;
|
||||
NetMsg_TextMsg( pbuf, iSize, destination, message );
|
||||
|
||||
|
||||
if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
|
||||
return 1;
|
||||
|
||||
|
@ -176,6 +176,24 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf
|
|||
psz[0] = 1;
|
||||
origin = psz + 1;
|
||||
}
|
||||
|
||||
// Ensure that message[0] does not contain exessive %'s, max 4x%s, all other %'s removed.
|
||||
int lastpos = 0; int pos; int count = 0;
|
||||
while(true)
|
||||
{
|
||||
pos = message[0].find("%", lastpos);
|
||||
|
||||
if (pos == string::npos)
|
||||
break;
|
||||
|
||||
if ((message[0].substr(pos + 1, 1) == "s") && (count < 4))
|
||||
count++;
|
||||
else
|
||||
message[0].replace(pos, 1, " ");
|
||||
|
||||
lastpos = pos + 1;
|
||||
}
|
||||
|
||||
sprintf( origin, message[0].c_str(), message[1].c_str(), message[2].c_str(), message[3].c_str(), message[4].c_str() );
|
||||
ConvertCRtoNL(psz);
|
||||
|
||||
|
|
Loading…
Reference in a new issue