[ioquake3] 01/09: Don't allow qagame module to create "botlib.log" at ANY filesystem location

Simon McVittie smcv at debian.org
Thu Jan 11 09:34:20 UTC 2018


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag debian/1.36+u20180108_dfsg-1
in repository ioquake3.

commit f3bdd6f022555fbff4528105c670354893880f90
Author: Eugene C <tweels at gmail.com>
Date:   Sun Dec 24 00:41:13 2017 +0200

    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 415c1b2..eb0efb9 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 ba51e00..0cfd491 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 <string.h>
 
 #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);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git



More information about the Pkg-games-commits mailing list