Browse Source

Fix out of bound access: strncat's size parameter is for the source, not the target

Samuel Thibault 8 years ago
parent
commit
2ebe25efed
1 changed files with 1 additions and 3 deletions
  1. 1 3
      src/common/fxt.c

+ 1 - 3
src/common/fxt.c

@@ -85,8 +85,6 @@ static void _starpu_profile_set_tracefile(void)
 	if (!fxt_prefix)
 	if (!fxt_prefix)
 	     fxt_prefix = "/tmp/";
 	     fxt_prefix = "/tmp/";
 
 
-	snprintf(_STARPU_PROF_FILE_USER, sizeof(_STARPU_PROF_FILE_USER), "%s", fxt_prefix);
-
 	user = starpu_getenv("USER");
 	user = starpu_getenv("USER");
 	if (!user)
 	if (!user)
 		user = "";
 		user = "";
@@ -94,7 +92,7 @@ static void _starpu_profile_set_tracefile(void)
 	char suffix[128];
 	char suffix[128];
 	snprintf(suffix, sizeof(suffix), "prof_file_%s_%d", user, _starpu_id);
 	snprintf(suffix, sizeof(suffix), "prof_file_%s_%d", user, _starpu_id);
 
 
-	strncat(_STARPU_PROF_FILE_USER, suffix, sizeof(_STARPU_PROF_FILE_USER));
+	snprintf(_STARPU_PROF_FILE_USER, sizeof(_STARPU_PROF_FILE_USER), "%s%s", fxt_prefix, suffix);
 }
 }
 
 
 void starpu_profiling_set_id(int new_id)
 void starpu_profiling_set_id(int new_id)