Skip to content

Commit 3bfaf01

Browse files
committed
create_tempfile: make sure that leading directories can be accessible by peers
In a shared repository, we should make sure adjust_shared_perm() is called after creating the initial fan-out directories under objects/ directory. Earlier an logico called the function only when mkdir() failed; we should do so when mkdir() succeeded. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1421c5f commit 3bfaf01

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sha1_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int safe_create_leading_directories(char *path)
116116
return 0;
117117
}
118118

119-
char * sha1_to_hex(const unsigned char *sha1)
119+
char *sha1_to_hex(const unsigned char *sha1)
120120
{
121121
static int bufno;
122122
static char hexbuffer[4][50];
@@ -2125,7 +2125,7 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
21252125
if (fd < 0 && dirlen) {
21262126
/* Make sure the directory exists */
21272127
buffer[dirlen-1] = 0;
2128-
if (mkdir(buffer, 0777) && adjust_shared_perm(buffer))
2128+
if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
21292129
return -1;
21302130

21312131
/* Try again */

0 commit comments

Comments
 (0)