mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-02-04 19:14:30 +00:00
More safe string copying.
This commit is contained in:
parent
4ba4f5a9bc
commit
813aa0ae91
@ -355,13 +355,15 @@ void Host_Say( edict_t *pEntity, int teamonly )
|
|||||||
{
|
{
|
||||||
if( CMD_ARGC() >= 2 )
|
if( CMD_ARGC() >= 2 )
|
||||||
{
|
{
|
||||||
sprintf( szTemp, "%s %s", (char *)pcmd, (char *)CMD_ARGS() );
|
_snprintf( szTemp, sizeof(szTemp) - 1, "%s %s", (char *)pcmd, (char *)CMD_ARGS() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Just a one word command, use the first word...sigh
|
// Just a one word command, use the first word...sigh
|
||||||
sprintf( szTemp, "%s", (char *)pcmd );
|
strncpy( szTemp, (char *)pcmd, sizeof(szTemp) - 1 );
|
||||||
}
|
}
|
||||||
|
szTemp[sizeof(szTemp) - 1] = '\0';
|
||||||
|
|
||||||
p = szTemp;
|
p = szTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,11 +379,12 @@ void Host_Say( edict_t *pEntity, int teamonly )
|
|||||||
|
|
||||||
// turn on color set 2 (color on, no sound)
|
// turn on color set 2 (color on, no sound)
|
||||||
if( player->IsObserver() && ( teamonly ) )
|
if( player->IsObserver() && ( teamonly ) )
|
||||||
sprintf( text, "%c(SPEC) %s: ", 2, STRING( pEntity->v.netname ) );
|
_snprintf( text, sizeof(text) - 1, "%c(SPEC) %s: ", 2, STRING( pEntity->v.netname ) );
|
||||||
else if( teamonly )
|
else if( teamonly )
|
||||||
sprintf( text, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) );
|
_snprintf( text, sizeof(text) - 1, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) );
|
||||||
else
|
else
|
||||||
sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) );
|
_snprintf( text, sizeof(text) - 1, "%c%s: ", 2, STRING( pEntity->v.netname ) );
|
||||||
|
text[sizeof(text) - 1] = '\0';
|
||||||
|
|
||||||
j = sizeof( text ) - 2 - strlen( text ); // -2 for /n and null terminator
|
j = sizeof( text ) - 2 - strlen( text ); // -2 for /n and null terminator
|
||||||
if( (int)strlen( p ) > j )
|
if( (int)strlen( p ) > j )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user