mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
Don't allow qagame module to create "botlib.log" at ANY filesystem location
This commit is contained in:
parent
7166a3cd39
commit
f3bdd6f022
2 changed files with 5 additions and 21 deletions
|
@ -144,26 +144,7 @@ int Export_BotLibSetup(void)
|
||||||
|
|
||||||
if(botDeveloper)
|
if(botDeveloper)
|
||||||
{
|
{
|
||||||
char *homedir, *gamedir, *basegame;
|
Log_Open("botlib.log");
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
botimport.Print(PRT_MESSAGE, "------- BotLib Initialization -------\n");
|
botimport.Print(PRT_MESSAGE, "------- BotLib Initialization -------\n");
|
||||||
|
|
|
@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../qcommon/q_shared.h"
|
#include "../qcommon/q_shared.h"
|
||||||
|
#include "../qcommon/qcommon.h"
|
||||||
#include "botlib.h"
|
#include "botlib.h"
|
||||||
#include "be_interface.h" //for botimport.Print
|
#include "be_interface.h" //for botimport.Print
|
||||||
#include "l_libvar.h"
|
#include "l_libvar.h"
|
||||||
|
@ -58,6 +59,7 @@ static logfile_t logfile;
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void Log_Open(char *filename)
|
void Log_Open(char *filename)
|
||||||
{
|
{
|
||||||
|
char *ospath;
|
||||||
if (!LibVarValue("log", "0")) return;
|
if (!LibVarValue("log", "0")) return;
|
||||||
if (!filename || !strlen(filename))
|
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);
|
botimport.Print(PRT_ERROR, "log file %s is already opened\n", logfile.filename);
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
logfile.fp = fopen(filename, "wb");
|
ospath = FS_BuildOSPath(Cvar_VariableString("fs_homepath"), "", filename);
|
||||||
|
logfile.fp = fopen(ospath, "wb");
|
||||||
if (!logfile.fp)
|
if (!logfile.fp)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_ERROR, "can't open the log file %s\n", filename);
|
botimport.Print(PRT_ERROR, "can't open the log file %s\n", filename);
|
||||||
|
|
Loading…
Reference in a new issue