2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-24 10:50:48 +01:00

More safe _snprintf usage.

This commit is contained in:
Andrey Akhmichin 2022-11-14 08:19:12 +05:00
parent cea0903626
commit 368fdf1259
No known key found for this signature in database
GPG Key ID: 1F180D249B0643C0

View File

@ -109,7 +109,10 @@ void ClientDisconnect( edict_t *pEntity )
char text[256] = ""; char text[256] = "";
if( pEntity->v.netname ) if( pEntity->v.netname )
_snprintf( text, sizeof(text), "- %s has left the game\n", STRING( pEntity->v.netname ) ); {
_snprintf( text, sizeof(text) - 1, "- %s has left the game\n", STRING( pEntity->v.netname ) );
text[sizeof(text) - 1] = '\0';
}
MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_BYTE( ENTINDEX( pEntity ) );
WRITE_STRING( text ); WRITE_STRING( text );
@ -667,7 +670,8 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer )
if( gpGlobals->maxClients > 1 ) if( gpGlobals->maxClients > 1 )
{ {
char text[256]; char text[256];
_snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); _snprintf( text, sizeof(text) - 1, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
text[sizeof(text) - 1] = '\0';
MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_BYTE( ENTINDEX( pEntity ) );
WRITE_STRING( text ); WRITE_STRING( text );