@matheusbsbs / matheus-bagliano / commits / 9fa03c177f
Fork 0

Fix potentially dangerous uses of mkpath and git_path

Replace them with mksnpath/git_snpath and a local buffer for the resulting string. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alex Riesen committed Oct 26, 2008 at 23:08 UTC 9fa03c177ff826b439537072338af958fe01c257
1 file changed +2 -2
builtin-apply.c
+2 -2
@@ -2850,8 +2850,8 @@ static void create_one_file(char *path, unsigned mode, const char *buf, unsigned
2850 unsigned int nr = getpid();
2851
2852 for (;;) {
2853 - const char *newpath;
2854 - newpath = mkpath("%s~%u", path, nr);
2853 + char newpath[PATH_MAX];
2854 + mksnpath(newpath, sizeof(newpath), "%s~%u", path, nr);
2855 if (!try_create_file(newpath, mode, buf, size)) {
2856 if (!rename(newpath, path))
2857 return;