]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
fix a buffer overflow due to a string not being large enough to store ending \0
authorThomas Debesse <dev@illwieckz.net>
Tue, 14 Jan 2020 04:39:45 +0000 (05:39 +0100)
committerThomas Debesse <dev@illwieckz.net>
Mon, 20 Jan 2020 19:52:41 +0000 (20:52 +0100)
tools/quake3/q3map2/path_init.c

index 59d9de3d1cffba6b3f5d86532ffe5003e4a44283..322173c95509f9ea009959a36e3ecb4838414216 100644 (file)
@@ -117,14 +117,14 @@ void LokiInitPaths( char *argv0 ){
 
        #if GDEF_OS_MACOS
        char *subPath = "/Library/Application Support";
-       macLibraryApplicationSupportPath = safe_malloc( sizeof( char ) * ( strlen( home ) + strlen( subPath ) ) );
+       macLibraryApplicationSupportPath = safe_malloc( sizeof( char ) * ( strlen( home ) + strlen( subPath ) ) + 1 );
        sprintf( macLibraryApplicationSupportPath, "%s%s", home, subPath );
        #elif GDEF_OS_XDG
        xdgDataHomePath = getenv( "XDG_DATA_HOME" );
 
        if ( xdgDataHomePath == NULL ) {
                char *subPath = "/.local/share";
-               xdgDataHomePath = safe_malloc( sizeof( char ) * ( strlen( home ) + strlen( subPath ) ) );
+               xdgDataHomePath = safe_malloc( sizeof( char ) * ( strlen( home ) + strlen( subPath ) ) + 1 );
                sprintf( xdgDataHomePath, "%s%s", home, subPath );
        }
        #endif // GDEF_OS_XDG