mirror of
https://github.com/git/git.git
synced 2024-10-28 12:59:41 +01:00
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>
This commit is contained in:
parent
94cc355287
commit
9fa03c177f
1 changed files with 2 additions and 2 deletions
|
@ -2850,8 +2850,8 @@ static void create_one_file(char *path, unsigned mode, const char *buf, unsigned
|
|||
unsigned int nr = getpid();
|
||||
|
||||
for (;;) {
|
||||
const char *newpath;
|
||||
newpath = mkpath("%s~%u", path, nr);
|
||||
char newpath[PATH_MAX];
|
||||
mksnpath(newpath, sizeof(newpath), "%s~%u", path, nr);
|
||||
if (!try_create_file(newpath, mode, buf, size)) {
|
||||
if (!rename(newpath, path))
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue