From e5845e0cabff35dc674ad5422799a02c025228f0 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Wed, 1 Aug 2012 09:52:49 +0200 Subject: [PATCH] add a #define HARDENING for the file extension checking (more to come) --- cl_demo.c | 4 ++-- host_cmd.c | 4 ++-- quakedef.h | 6 ++++++ sv_demo.c | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cl_demo.c b/cl_demo.c index 9adb0de5..81bb469b 100644 --- a/cl_demo.c +++ b/cl_demo.c @@ -370,7 +370,7 @@ void CL_Record_f (void) // get the demo name strlcpy (name, Cmd_Argv(1), sizeof (name)); - FS_SetExtension (name, ".dem", sizeof (name), true); + FS_SetExtension (name, ".dem", sizeof (name), IS_HARDENED); // start the map up if (c > 2) @@ -417,7 +417,7 @@ void CL_PlayDemo_f (void) // open the demo file strlcpy (name, Cmd_Argv(1), sizeof (name)); - FS_SetExtension (name, ".dem", sizeof (name), true); + FS_SetExtension (name, ".dem", sizeof (name), IS_HARDENED); f = FS_OpenVirtualFile(name, false); if (!f) { diff --git a/host_cmd.c b/host_cmd.c index 1a8112b8..b3d3771c 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -741,7 +741,7 @@ static void Host_Savegame_f (void) } strlcpy (name, Cmd_Argv(1), sizeof (name)); - FS_SetExtension (name, ".sav", sizeof (name), true); + FS_SetExtension (name, ".sav", sizeof (name), IS_HARDENED); Host_Savegame_to(prog, name); } @@ -778,7 +778,7 @@ static void Host_Loadgame_f (void) } strlcpy (filename, Cmd_Argv(1), sizeof(filename)); - FS_SetExtension (filename, ".sav", sizeof (filename), true); + FS_SetExtension (filename, ".sav", sizeof (filename), IS_HARDENED); Con_Printf("Loading game from %s...\n", filename); diff --git a/quakedef.h b/quakedef.h index 3b594916..a9a705ed 100644 --- a/quakedef.h +++ b/quakedef.h @@ -32,6 +32,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define DP_FUNC_NORETURN #endif +#ifdef HARDENING +# define IS_HARDENED false +#else +# define IS_HARDENED true +#endif + #ifdef ANTICHEAT #define _GNU_SOURCE // for memmem #endif diff --git a/sv_demo.c b/sv_demo.c index 63d919a4..7741b0a4 100644 --- a/sv_demo.c +++ b/sv_demo.c @@ -12,7 +12,7 @@ void SV_StartDemoRecording(client_t *client, const char *filename, int forcetrac return; // we already have a demo strlcpy(name, filename, sizeof(name)); - FS_SetExtension(name, ".dem", sizeof(name), true); + FS_SetExtension(name, ".dem", sizeof(name), IS_HARDENED); Con_Printf("Recording demo for # %d (%s) to %s\n", PRVM_NUM_FOR_EDICT(client->edict), client->netaddress, name); -- 2.39.2