Merge branch 'sw/safe-create-leading-dir-race'

* sw/safe-create-leading-dir-race:
  safe_create_leading_directories: fix race that could give a false negative
This commit is contained in:
Junio C Hamano 2013-04-02 15:09:48 -07:00
commit 37ba4c61d0

View file

@ -124,8 +124,13 @@ int safe_create_leading_directories(char *path)
}
}
else if (mkdir(path, 0777)) {
*pos = '/';
return -1;
if (errno == EEXIST &&
!stat(path, &st) && S_ISDIR(st.st_mode)) {
; /* somebody created it since we checked */
} else {
*pos = '/';
return -1;
}
}
else if (adjust_shared_perm(path)) {
*pos = '/';