From: Thomas Debesse Date: Tue, 14 Jan 2020 04:39:45 +0000 (+0100) Subject: fix a buffer overflow due to a string not being large enough to store ending \0 X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=abe197a9634c5dc74b9610a7c31f1a58405d3d28 fix a buffer overflow due to a string not being large enough to store ending \0 --- diff --git a/tools/quake3/q3map2/path_init.c b/tools/quake3/q3map2/path_init.c index 59d9de3d..322173c9 100644 --- a/tools/quake3/q3map2/path_init.c +++ b/tools/quake3/q3map2/path_init.c @@ -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