From abe197a9634c5dc74b9610a7c31f1a58405d3d28 Mon Sep 17 00:00:00 2001
From: Thomas Debesse <dev@illwieckz.net>
Date: Tue, 14 Jan 2020 05:39:45 +0100
Subject: [PATCH] fix a buffer overflow due to a string not being large enough
 to store ending \0

---
 tools/quake3/q3map2/path_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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
-- 
2.39.5