From 91c23e48d0666a673dd14760bb00f6d59234d9d9 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 31 Oct 2006 15:56:58 -0800 Subject: link_temp_to_file: don't leave the path truncated on adjust_shared_perm failure Signed-off-by: Junio C Hamano --- sha1_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sha1_file.c') diff --git a/sha1_file.c b/sha1_file.c index 47e2a29abd..5fcad2893f 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1383,8 +1383,10 @@ static int link_temp_to_file(const char *tmpfile, const char *filename) if (dir) { *dir = 0; mkdir(filename, 0777); - if (adjust_shared_perm(filename)) + if (adjust_shared_perm(filename)) { + *dir = '/'; return -2; + } *dir = '/'; if (!link(tmpfile, filename)) return 0; -- cgit v1.2.1 From 866cae0db4af936ec6f9eb6362e50db2a1a2f792 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 2 Nov 2006 18:02:17 -0800 Subject: link_temp_to_file: call adjust_shared_perm() only when we created the directory --- sha1_file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sha1_file.c') diff --git a/sha1_file.c b/sha1_file.c index 5fcad2893f..27eb14b922 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1382,8 +1382,7 @@ static int link_temp_to_file(const char *tmpfile, const char *filename) dir = strrchr(filename, '/'); if (dir) { *dir = 0; - mkdir(filename, 0777); - if (adjust_shared_perm(filename)) { + if (!mkdir(filename, 0777) && adjust_shared_perm(filename)) { *dir = '/'; return -2; } -- cgit v1.2.1