Skip to content
Permalink
Browse files Browse the repository at this point in the history
All: Merge some file writing extension checks
  • Loading branch information
MAN-AT-ARMS committed Mar 14, 2017
1 parent b248763 commit 11a8341
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions MP/code/client/cl_console.c
Expand Up @@ -227,6 +227,12 @@ void Con_Dump_f( void ) {
Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
COM_DefaultExtension( filename, sizeof( filename ), ".txt" );

if (!COM_CompareExtension(filename, ".txt"))
{
Com_Printf("Con_Dump_f: Only the \".txt\" extension is supported by this command!\n");
return;
}

f = FS_FOpenFileWrite( filename );
if ( !f ) {
Com_Printf ("ERROR: couldn't open %s.\n", filename);
Expand Down
6 changes: 6 additions & 0 deletions MP/code/qcommon/common.c
Expand Up @@ -3058,6 +3058,12 @@ void Com_WriteConfig_f( void ) {
return;
}

if (!COM_CompareExtension(filename, ".cfg"))
{
Com_Printf("Com_WriteConfig_f: Only the \".cfg\" extension is supported by this command!\n");
return;
}

Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
COM_DefaultExtension( filename, sizeof( filename ), ".cfg" );
Com_Printf( "Writing %s.\n", filename );
Expand Down
6 changes: 6 additions & 0 deletions SP/code/client/cl_console.c
Expand Up @@ -219,6 +219,12 @@ void Con_Dump_f( void ) {
Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
COM_DefaultExtension( filename, sizeof( filename ), ".txt" );

if (!COM_CompareExtension(filename, ".txt"))
{
Com_Printf("Con_Dump_f: Only the \".txt\" extension is supported by this command!\n");
return;
}

f = FS_FOpenFileWrite( filename );
if ( !f ) {
Com_Printf ("ERROR: couldn't open %s.\n", filename);
Expand Down
6 changes: 6 additions & 0 deletions SP/code/qcommon/common.c
Expand Up @@ -2601,6 +2601,12 @@ void Com_WriteConfig_f( void ) {
return;
}

if (!COM_CompareExtension(filename, ".cfg"))
{
Com_Printf("Com_WriteConfig_f: Only the \".cfg\" extension is supported by this command!\n");
return;
}

Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
COM_DefaultExtension( filename, sizeof( filename ), ".cfg" );
Com_Printf( "Writing %s.\n", filename );
Expand Down

0 comments on commit 11a8341

Please sign in to comment.