From: Rudolf Polzer Date: Sat, 13 Jul 2013 09:30:40 +0000 (+0200) Subject: kill some more evil X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=47cc2cc72684600e434a8ee2e7f4685d54d9fa39;p=xonotic%2Fdarkplaces.git kill some more evil --- diff --git a/cl_parse.c b/cl_parse.c index 4b8da407..a465f910 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -2992,6 +2992,12 @@ static void CL_IPLog_Add(const char *address, const char *name, qboolean checkex if (addtofile) { // add it to the iplog.txt file + { + char name[MAX_OSPATH]; + strlcpy(name, cl_iplog_name.string, sizeof(name)); + FS_SetExtension(name, ".log", sizeof (name), IS_HARDENED); + Cvar_SetQuick(cl_iplog_name, name); + } // TODO: this ought to open the one in the userpath version of the base // gamedir, not the current gamedir Log_Printf(cl_iplog_name.string, "%s %s\n", address, name); @@ -3009,6 +3015,12 @@ static void CL_IPLog_Load(void) char line[MAX_INPUTLINE]; char address[MAX_INPUTLINE]; cl_iplog_loaded = true; + { + char name[MAX_OSPATH]; + strlcpy(name, cl_iplog_name.string, sizeof(name)); + FS_SetExtension(name, ".log", sizeof (name), IS_HARDENED); + Cvar_SetQuick(cl_iplog_name, name); + } // TODO: this ought to open the one in the userpath version of the base // gamedir, not the current gamedir filedata = FS_LoadFile(cl_iplog_name.string, tempmempool, true, &filesize); diff --git a/console.c b/console.c index e21f2cbf..be14fca1 100644 --- a/console.c +++ b/console.c @@ -410,6 +410,13 @@ static void Log_Open (void) if (logfile != NULL || log_file.string[0] == '\0') return; + { + char name[MAX_OSPATH]; + strlcpy(name, log_file.string, sizeof(name)); + FS_SetExtension(name, ".log", sizeof (name), IS_HARDENED); + Cvar_SetQuick(log_file, name); + } + logfile = FS_OpenRealFile(log_file.string, "a", false); if (logfile != NULL) { @@ -692,12 +699,15 @@ static void Con_ConDump_f (void) { int i; qfile_t *file; + char name[MAX_OSPATH]; if (Cmd_Argc() != 2) { Con_Printf("usage: condump \n"); return; } - file = FS_OpenRealFile(Cmd_Argv(1), "w", false); + strlcpy(name, Cmd_Argv(1), sizeof(name)); + FS_SetExtension(name, ".txt", sizeof (name), IS_HARDENED); + file = FS_OpenRealFile(name, "w", false); if (!file) { Con_Printf("condump: unable to write file \"%s\"\n", Cmd_Argv(1)); diff --git a/host.c b/host.c index 7bc799dd..ce6abbd1 100644 --- a/host.c +++ b/host.c @@ -276,16 +276,20 @@ Writes key bindings and archived cvars to config.cfg static void Host_SaveConfig_to(const char *file) { qfile_t *f; + char name[MAX_OSPATH]; + + strlcpy(name, file, sizeof(name)); + FS_SetExtension(name, ".cfg", sizeof (name), IS_HARDENED); // dedicated servers initialize the host but don't parse and set the // config.cfg cvars // LordHavoc: don't save a config if it crashed in startup if (host_framecount >= 3 && cls.state != ca_dedicated && !COM_CheckParm("-benchmark") && !COM_CheckParm("-capturedemo")) { - f = FS_OpenRealFile(file, "wb", false); + f = FS_OpenRealFile(name, "wb", false); if (!f) { - Con_Printf("Couldn't write %s.\n", file); + Con_Printf("Couldn't write %s.\n", name); return; }