From 938363014f85d1ebd30bc110e3e889e4169dca21 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 27 Apr 2021 03:30:54 +0200 Subject: [PATCH] q3map2: do not leak user temporary paths do not write in "_q3map2_cmdline" worldspawn entity key user paths like: -lightmapdir -bspfile -prtfile -srffile -linfile --- tools/quake3/q3map2/bsp.c | 8 ++++++++ tools/quake3/q3map2/bspfile_abstract.c | 3 +++ tools/quake3/q3map2/light.c | 6 ++++++ tools/quake3/q3map2/vis.c | 2 ++ 4 files changed, 19 insertions(+) diff --git a/tools/quake3/q3map2/bsp.c b/tools/quake3/q3map2/bsp.c index e2bc46cc..bd0abc20 100644 --- a/tools/quake3/q3map2/bsp.c +++ b/tools/quake3/q3map2/bsp.c @@ -1020,25 +1020,33 @@ int BSPMain( int argc, char **argv ){ else if ( !strcmp( argv[ i ], "-bspfile" ) ) { strcpy( BSPFilePath, argv[i + 1] ); + argv[ i ] = NULL; i++; + argv[ i ] = NULL; Sys_Printf( "Use %s as bsp file\n", BSPFilePath ); } else if ( !strcmp( argv[ i ], "-linfile" ) ) { strcpy( lineFilePath, argv[i + 1] ); + argv[ i ] = NULL; i++; + argv[ i ] = NULL; Sys_Printf( "Use %s as line file\n", lineFilePath ); } else if ( !strcmp( argv[ i ], "-prtfile" ) ) { strcpy( portalFilePath, argv[i + 1] ); + argv[ i ] = NULL; i++; + argv[ i ] = NULL; Sys_Printf( "Use %s as portal file\n", portalFilePath ); } else if ( !strcmp( argv[ i ], "-srffile" ) ) { strcpy( surfaceFilePath, argv[i + 1] ); + argv[ i ] = NULL; i++; + argv[ i ] = NULL; Sys_Printf( "Use %s as surface file\n", surfaceFilePath ); } else{ diff --git a/tools/quake3/q3map2/bspfile_abstract.c b/tools/quake3/q3map2/bspfile_abstract.c index 675aef6d..db14ea45 100644 --- a/tools/quake3/q3map2/bspfile_abstract.c +++ b/tools/quake3/q3map2/bspfile_abstract.c @@ -604,6 +604,9 @@ void InjectCommandLine( char **argv, int beginArgs, int endArgs ){ for ( i = beginArgs; i < endArgs; ++i ) { + if ( argv[i] == NULL ) { + continue; + } if ( outpos != sentinel && i != beginArgs ) { *outpos++ = ' '; } diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index 709b2ab9..bedc3f17 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -2573,7 +2573,9 @@ int LightMain( int argc, char **argv ){ else if ( !strcmp( argv[ i ], "-lightmapdir" ) ) { lmCustomDir = argv[i + 1]; + argv[ i ] = NULL; i++; + argv[ i ] = NULL; Sys_Printf( "Lightmap directory set to %s\n", lmCustomDir ); externalLightmaps = qtrue; Sys_Printf( "Storing all lightmaps externally\n" ); @@ -2929,13 +2931,17 @@ int LightMain( int argc, char **argv ){ else if ( !strcmp( argv[ i ], "-bspfile" ) ) { strcpy( BSPFilePath, argv[i + 1] ); + argv[ i ] = NULL; i++; + argv[ i ] = NULL; Sys_Printf( "Use %s as bsp file\n", BSPFilePath ); } else if ( !strcmp( argv[ i ], "-srffile" ) ) { strcpy( surfaceFilePath, argv[i + 1] ); + argv[ i ] = NULL; i++; + argv[ i ] = NULL; Sys_Printf( "Use %s as surface file\n", surfaceFilePath ); } /* unhandled args */ diff --git a/tools/quake3/q3map2/vis.c b/tools/quake3/q3map2/vis.c index ef05a3dc..588765ee 100644 --- a/tools/quake3/q3map2/vis.c +++ b/tools/quake3/q3map2/vis.c @@ -1155,7 +1155,9 @@ int VisMain( int argc, char **argv ){ else if ( !strcmp( argv[ i ], "-prtfile" ) ) { strcpy( portalFilePath, argv[i + 1] ); + argv[ i ] = NULL; i++; + argv[ i ] = NULL; Sys_Printf( "Use %s as portal file\n", portalFilePath ); } -- 2.39.2