public: remove Q_strcat and Q_strcpy, and patch the code that uses it

This commit is contained in:
Alibek Omarov
2023-04-26 05:20:45 +03:00
parent 2261b0dcab
commit b16fa8eddc
23 changed files with 68 additions and 57 deletions
+4 -4
View File
@@ -1162,13 +1162,13 @@ void Cmd_ForwardToServer( void )
str[0] = 0;
if( Q_stricmp( Cmd_Argv( 0 ), "cmd" ))
{
Q_strcat( str, Cmd_Argv( 0 ));
Q_strcat( str, " " );
Q_strncat( str, Cmd_Argv( 0 ), sizeof( str ));
Q_strncat( str, " ", sizeof( str ));
}
if( Cmd_Argc() > 1 )
Q_strcat( str, Cmd_Args( ));
else Q_strcat( str, "\n" );
Q_strncat( str, Cmd_Args( ), sizeof( str ));
else Q_strncat( str, "\n", sizeof( str ));
MSG_WriteString( &cls.netchan.message, str );
}
+5 -4
View File
@@ -1006,7 +1006,7 @@ pfnGetGameDir
void GAME_EXPORT pfnGetGameDir( char *szGetGameDir )
{
if( !szGetGameDir ) return;
Q_strcpy( szGetGameDir, GI->gamefolder );
Q_strncpy( szGetGameDir, GI->gamefolder, sizeof( GI->gamefolder ));
}
qboolean COM_IsSafeFileToDownload( const char *filename )
@@ -1070,13 +1070,15 @@ const char *COM_GetResourceTypeName( resourcetype_t restype )
char *_copystring( poolhandle_t mempool, const char *s, const char *filename, int fileline )
{
size_t size;
char *b;
if( !s ) return NULL;
if( !mempool ) mempool = host.mempool;
b = _Mem_Alloc( mempool, Q_strlen( s ) + 1, false, filename, fileline );
Q_strcpy( b, s );
size = Q_strlen( s ) + 1;
b = _Mem_Alloc( mempool, size, false, filename, fileline );
Q_strncpy( b, s, size );
return b;
}
@@ -1101,7 +1103,6 @@ void *GAME_EXPORT pfnSequenceGet( const char *fileName, const char *entryName )
{
Msg( "Sequence_Get: file %s, entry %s\n", fileName, entryName );
return Sequence_Get( fileName, entryName );
}
+3 -3
View File
@@ -571,7 +571,7 @@ qboolean Cmd_GetKeysList( const char *s, char *completedname, int length )
const char *keyname = Key_KeynumToString( i );
if(( *s == '*' ) || !Q_strnicmp( keyname, s, len))
Q_strcpy( keys[numkeys++], keyname );
Q_strncpy( keys[numkeys++], keyname, sizeof( keys[0] ));
}
if( !numkeys ) return false;
@@ -765,7 +765,7 @@ qboolean Cmd_GetGamesList( const char *s, char *completedname, int length )
for( i = 0, numgamedirs = 0; i < FI->numgames; i++ )
{
if(( *s == '*' ) || !Q_strnicmp( FI->games[i]->gamefolder, s, len))
Q_strcpy( gamedirs[numgamedirs++], FI->games[i]->gamefolder );
Q_strncpy( gamedirs[numgamedirs++], FI->games[i]->gamefolder, sizeof( gamedirs[0] ));
}
if( !numgamedirs ) return false;
@@ -826,7 +826,7 @@ qboolean Cmd_GetCDList( const char *s, char *completedname, int length )
for( i = 0, numcdcommands = 0; i < 8; i++ )
{
if(( *s == '*' ) || !Q_strnicmp( cd_command[i], s, len))
Q_strcpy( cdcommands[numcdcommands++], cd_command[i] );
Q_strncpy( cdcommands[numcdcommands++], cd_command[i], sizeof( cdcommands[0] ));
}
if( !numcdcommands ) return false;
+2 -2
View File
@@ -1119,8 +1119,8 @@ void Cvar_Set_f( void )
len = Q_strlen( Cmd_Argv(i) + 1 );
if( l + len >= MAX_CMD_TOKENS - 2 )
break;
Q_strcat( combined, Cmd_Argv( i ));
if( i != c-1 ) Q_strcat( combined, " " );
Q_strncat( combined, Cmd_Argv( i ), sizeof( combined ));
if( i != c-1 ) Q_strncat( combined, " ", sizeof( combined ));
l += len;
}
+3 -1
View File
@@ -277,7 +277,9 @@ qboolean GAME_EXPORT Info_RemoveKey( char *s, const char *key )
if( !Q_strncmp( key, pkey, cmpsize ))
{
Q_strcpy( start, s ); // remove this part
size_t size = Q_strlen( s ) + 1;
memmove( start, s, size ); // remove this part
return true;
}
+1 -1
View File
@@ -1827,7 +1827,7 @@ static void Mod_LoadEntities( dbspmodel_t *bmod )
wadstring[MAX_TOKEN - 2] = 0;
if( !Q_strchr( wadstring, ';' ))
Q_strcat( wadstring, ";" );
Q_strncat( wadstring, ";", sizeof( wadstring ));
// parse wad pathes
for( pszWadFile = strtok( wadstring, ";" ); pszWadFile != NULL; pszWadFile = strtok( NULL, ";" ))
+2 -2
View File
@@ -273,8 +273,8 @@ void Netchan_ReportFlow( netchan_t *chan )
Assert( chan != NULL );
Q_strcpy( incoming, Q_pretifymem((float)chan->flow[FLOW_INCOMING].totalbytes, 3 ));
Q_strcpy( outgoing, Q_pretifymem((float)chan->flow[FLOW_OUTGOING].totalbytes, 3 ));
Q_strncpy( incoming, Q_pretifymem((float)chan->flow[FLOW_INCOMING].totalbytes, 3 ), sizeof( incoming ));
Q_strncpy( outgoing, Q_pretifymem((float)chan->flow[FLOW_OUTGOING].totalbytes, 3 ), sizeof( outgoing ));
Con_DPrintf( "Signon network traffic: %s from server, %s to server\n", incoming, outgoing );
}
+1 -1
View File
@@ -793,7 +793,7 @@ static void Delta_InitFields( void )
pfile = COM_ParseFile( pfile, encodeDll, sizeof( encodeDll ));
if( !Q_stricmp( encodeDll, "none" ))
Q_strcpy( encodeFunc, "null" );
Q_strncpy( encodeFunc, "null", sizeof( encodeFunc ));
else pfile = COM_ParseFile( pfile, encodeFunc, sizeof( encodeFunc ));
// jump to '{'
+1 -1
View File
@@ -1556,7 +1556,7 @@ static void Sequence_ParseFile( const char *fileName, qboolean isGlobal )
byte *buffer;
fs_offset_t bufSize = 0;
Q_strcpy( g_sequenceParseFileName, fileName );
Q_strncpy( g_sequenceParseFileName, fileName, sizeof( g_sequenceParseFileName ));
g_sequenceParseFileIsGlobal = isGlobal;
buffer = FS_LoadFile( va("sequences/%s.seq", fileName ), &bufSize, true );