]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
q3map2: do not leak user temporary paths
authorThomas Debesse <dev@illwieckz.net>
Tue, 27 Apr 2021 01:30:54 +0000 (03:30 +0200)
committerThomas Debesse <dev@illwieckz.net>
Tue, 27 Apr 2021 01:40:44 +0000 (03:40 +0200)
do not write in "_q3map2_cmdline" worldspawn entity key user paths like:

  -lightmapdir
  -bspfile
  -prtfile
  -srffile
  -linfile

tools/quake3/q3map2/bsp.c
tools/quake3/q3map2/bspfile_abstract.c
tools/quake3/q3map2/light.c
tools/quake3/q3map2/vis.c

index e2bc46cca2a10c78bd2172d35c0a298bade3d864..bd0abc207b9bedcfa1437c196a74772006558a40 100644 (file)
@@ -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{
index 675aef6d3abd6d971333d720b2aa42a2649c9f64..db14ea452230674f9a835ad359e43f505022726d 100644 (file)
@@ -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++ = ' ';
                }
index 709b2ab996bc87ad8eb516d7da8baed799d0e841..bedc3f1770bf603d766d5126a84d5e575fe85418 100644 (file)
@@ -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 */
index ef05a3dcbea499414c2eebeb50fa4fa13f23eb3f..588765ee99e4e15b9d55b68f6c2fb63266dfd65d 100644 (file)
@@ -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 );
                }