Skip to content

Commit 9fa03c1

Browse files
raalkmlgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 94cc355 commit 9fa03c1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin-apply.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2850,8 +2850,8 @@ static void create_one_file(char *path, unsigned mode, const char *buf, unsigned
28502850
unsigned int nr = getpid();
28512851

28522852
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);
28552855
if (!try_create_file(newpath, mode, buf, size)) {
28562856
if (!rename(newpath, path))
28572857
return;

0 commit comments

Comments
 (0)