From b173ac05993f634a42be3d3535e1b158de0c3372 Mon Sep 17 00:00:00 2001 From: SmileTheory Date: Mon, 13 Mar 2017 20:44:47 -0700 Subject: [PATCH] Merge some file writing extension checks from OpenJK. Thanks Ensiform. https://github.com/JACoders/OpenJK/commit/05928a57f9e4aae15a3bd0 https://github.com/JACoders/OpenJK/commit/ef124fd0fc48af164581176 --- code/client/cl_console.c | 6 ++++++ code/qcommon/common.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/code/client/cl_console.c b/code/client/cl_console.c index 7d806e94..32ab87e0 100644 --- a/code/client/cl_console.c +++ b/code/client/cl_console.c @@ -191,6 +191,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) { diff --git a/code/qcommon/common.c b/code/qcommon/common.c index db9b435f..f3cf1214 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -2975,6 +2975,13 @@ 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 );