mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2024-11-21 12:11:07 +00:00
Use idStr::Copynz() instead of strncpy()
to guarantee \0-termination (only the applicable parts of that dhewm3 commit)
This commit is contained in:
parent
37cdb06dce
commit
9cc5bb2352
5 changed files with 7 additions and 7 deletions
|
@ -2639,7 +2639,7 @@ gameReturn_t idGameLocal::RunFrame( const usercmd_t *clientCmds ) {
|
|||
|
||||
// see if a target_sessionCommand has forced a changelevel
|
||||
if ( sessionCommand.Length() ) {
|
||||
strncpy( ret.sessionCommand, sessionCommand, sizeof( ret.sessionCommand ) );
|
||||
idStr::Copynz( ret.sessionCommand, sessionCommand, sizeof( ret.sessionCommand ) );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4836,7 +4836,7 @@ idGameLocal::GetBestGameType
|
|||
*/
|
||||
void idGameLocal::GetBestGameType( const char* map, const char* gametype, char buf[ MAX_STRING_CHARS ] ) {
|
||||
idStr aux = mpGame.GetBestGametype( map, gametype );
|
||||
strncpy( buf, aux.c_str(), MAX_STRING_CHARS );
|
||||
idStr::Copynz( buf, aux.c_str(), MAX_STRING_CHARS );
|
||||
buf[ MAX_STRING_CHARS - 1 ] = '\0';
|
||||
}
|
||||
|
||||
|
|
|
@ -1566,7 +1566,7 @@ gameReturn_t idGameLocal::ClientPrediction( int clientNum, const usercmd_t *clie
|
|||
}
|
||||
|
||||
if ( sessionCommand.Length() ) {
|
||||
strncpy( ret.sessionCommand, sessionCommand, sizeof( ret.sessionCommand ) );
|
||||
idStr::Copynz( ret.sessionCommand, sessionCommand, sizeof( ret.sessionCommand ) );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -2373,7 +2373,7 @@ gameReturn_t idGameLocal::RunFrame( const usercmd_t *clientCmds ) {
|
|||
|
||||
// see if a target_sessionCommand has forced a changelevel
|
||||
if ( sessionCommand.Length() ) {
|
||||
strncpy( ret.sessionCommand, sessionCommand, sizeof( ret.sessionCommand ) );
|
||||
idStr::Copynz( ret.sessionCommand, sessionCommand, sizeof( ret.sessionCommand ) );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4338,7 +4338,7 @@ idGameLocal::GetBestGameType
|
|||
============
|
||||
*/
|
||||
void idGameLocal::GetBestGameType( const char* map, const char* gametype, char buf[ MAX_STRING_CHARS ] ) {
|
||||
strncpy( buf, gametype, MAX_STRING_CHARS );
|
||||
idStr::Copynz( buf, gametype, MAX_STRING_CHARS );
|
||||
buf[ MAX_STRING_CHARS - 1 ] = '\0';
|
||||
}
|
||||
|
||||
|
|
|
@ -1521,7 +1521,7 @@ gameReturn_t idGameLocal::ClientPrediction( int clientNum, const usercmd_t *clie
|
|||
}
|
||||
|
||||
if ( sessionCommand.Length() ) {
|
||||
strncpy( ret.sessionCommand, sessionCommand, sizeof( ret.sessionCommand ) );
|
||||
idStr::Copynz( ret.sessionCommand, sessionCommand, sizeof( ret.sessionCommand ) );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1275,7 +1275,7 @@ const char *Mem_CleanupFileName( const char *fileName ) {
|
|||
newFileName = newFileName.Left( i2 - 1 ) + newFileName.Right( newFileName.Length() - ( i1 + 4 ) );
|
||||
}
|
||||
index = ( index + 1 ) & 3;
|
||||
strncpy( newFileNames[index], newFileName.c_str(), sizeof( newFileNames[index] ) );
|
||||
idStr::Copynz( newFileNames[index], newFileName.c_str(), sizeof( newFileNames[index] ) );
|
||||
return newFileNames[index];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue