From f3bdd6f022555fbff4528105c670354893880f90 Mon Sep 17 00:00:00 2001 From: Eugene C Date: Sun, 24 Dec 2017 00:41:13 +0200 Subject: [PATCH] Don't allow qagame module to create "botlib.log" at ANY filesystem location --- code/botlib/be_interface.c | 21 +-------------------- code/botlib/l_log.c | 5 ++++- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/code/botlib/be_interface.c b/code/botlib/be_interface.c index 415c1b2b..eb0efb95 100644 --- a/code/botlib/be_interface.c +++ b/code/botlib/be_interface.c @@ -144,26 +144,7 @@ int Export_BotLibSetup(void) if(botDeveloper) { - char *homedir, *gamedir, *basegame; - char logfilename[MAX_OSPATH]; - - homedir = LibVarGetString("homedir"); - gamedir = LibVarGetString("gamedir"); - basegame = LibVarGetString("basegame"); - - if (*homedir) - { - if(*gamedir) - Com_sprintf(logfilename, sizeof(logfilename), "%s%c%s%cbotlib.log", homedir, PATH_SEP, gamedir, PATH_SEP); - else if(*basegame) - Com_sprintf(logfilename, sizeof(logfilename), "%s%c%s%cbotlib.log", homedir, PATH_SEP, basegame, PATH_SEP); - else - Com_sprintf(logfilename, sizeof(logfilename), "%s%c" BASEGAME "%cbotlib.log", homedir, PATH_SEP, PATH_SEP); - } - else - Com_sprintf(logfilename, sizeof(logfilename), "botlib.log"); - - Log_Open(logfilename); + Log_Open("botlib.log"); } botimport.Print(PRT_MESSAGE, "------- BotLib Initialization -------\n"); diff --git a/code/botlib/l_log.c b/code/botlib/l_log.c index ba51e008..0cfd491c 100644 --- a/code/botlib/l_log.c +++ b/code/botlib/l_log.c @@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "../qcommon/q_shared.h" +#include "../qcommon/qcommon.h" #include "botlib.h" #include "be_interface.h" //for botimport.Print #include "l_libvar.h" @@ -58,6 +59,7 @@ static logfile_t logfile; //=========================================================================== void Log_Open(char *filename) { + char *ospath; if (!LibVarValue("log", "0")) return; if (!filename || !strlen(filename)) { @@ -69,7 +71,8 @@ void Log_Open(char *filename) botimport.Print(PRT_ERROR, "log file %s is already opened\n", logfile.filename); return; } //end if - logfile.fp = fopen(filename, "wb"); + ospath = FS_BuildOSPath(Cvar_VariableString("fs_homepath"), "", filename); + logfile.fp = fopen(ospath, "wb"); if (!logfile.fp) { botimport.Print(PRT_ERROR, "can't open the log file %s\n", filename);