Browse Source

More safe _snprintf usage.

fix-cwd-path
Andrey Akhmichin 2 years ago
parent
commit
368fdf1259
No known key found for this signature in database
GPG Key ID: 1F180D249B0643C0
  1. 8
      dlls/client.cpp

8
dlls/client.cpp

@ -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 );

Loading…
Cancel
Save