Skip to content

Commit 11a8341

Browse files
committed
All: Merge some file writing extension checks
1 parent b248763 commit 11a8341

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

Diff for: MP/code/client/cl_console.c

+6
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ void Con_Dump_f( void ) {
227227
Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
228228
COM_DefaultExtension( filename, sizeof( filename ), ".txt" );
229229

230+
if (!COM_CompareExtension(filename, ".txt"))
231+
{
232+
Com_Printf("Con_Dump_f: Only the \".txt\" extension is supported by this command!\n");
233+
return;
234+
}
235+
230236
f = FS_FOpenFileWrite( filename );
231237
if ( !f ) {
232238
Com_Printf ("ERROR: couldn't open %s.\n", filename);

Diff for: MP/code/qcommon/common.c

+6
Original file line numberDiff line numberDiff line change
@@ -3058,6 +3058,12 @@ void Com_WriteConfig_f( void ) {
30583058
return;
30593059
}
30603060

3061+
if (!COM_CompareExtension(filename, ".cfg"))
3062+
{
3063+
Com_Printf("Com_WriteConfig_f: Only the \".cfg\" extension is supported by this command!\n");
3064+
return;
3065+
}
3066+
30613067
Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
30623068
COM_DefaultExtension( filename, sizeof( filename ), ".cfg" );
30633069
Com_Printf( "Writing %s.\n", filename );

Diff for: SP/code/client/cl_console.c

+6
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ void Con_Dump_f( void ) {
219219
Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
220220
COM_DefaultExtension( filename, sizeof( filename ), ".txt" );
221221

222+
if (!COM_CompareExtension(filename, ".txt"))
223+
{
224+
Com_Printf("Con_Dump_f: Only the \".txt\" extension is supported by this command!\n");
225+
return;
226+
}
227+
222228
f = FS_FOpenFileWrite( filename );
223229
if ( !f ) {
224230
Com_Printf ("ERROR: couldn't open %s.\n", filename);

Diff for: SP/code/qcommon/common.c

+6
Original file line numberDiff line numberDiff line change
@@ -2601,6 +2601,12 @@ void Com_WriteConfig_f( void ) {
26012601
return;
26022602
}
26032603

2604+
if (!COM_CompareExtension(filename, ".cfg"))
2605+
{
2606+
Com_Printf("Com_WriteConfig_f: Only the \".cfg\" extension is supported by this command!\n");
2607+
return;
2608+
}
2609+
26042610
Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
26052611
COM_DefaultExtension( filename, sizeof( filename ), ".cfg" );
26062612
Com_Printf( "Writing %s.\n", filename );

0 commit comments

Comments
 (0)