Skip to content

Commit

Permalink
Fix potentially dangerous uses of mkpath and git_path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alex Riesen authored and Junio C Hamano committed Oct 27, 2008
1 parent 94cc355 commit 9fa03c1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions builtin-apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9fa03c1

Please sign in to comment.