Skip to content

Commit

Permalink
Merge pull request #2533 from dscho/try-stat-harder
Browse files Browse the repository at this point in the history
Fix clone within a directory whose parent isn't readable by the current user
  • Loading branch information
dscho committed Mar 6, 2020
2 parents 69fbeff + ee54f80 commit 120fb25
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,19 @@ int mingw_stat(const char *file_name, struct stat *buf)
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hnd == INVALID_HANDLE_VALUE) {
errno = err_win_to_posix(GetLastError());
DWORD err = GetLastError();

if (err == ERROR_ACCESS_DENIED &&
!mingw_lstat(file_name, buf) &&
!S_ISLNK(buf->st_mode))
/*
* POSIX semantics state to still try to fill
* information, even if permission is denied to create
* a file handle.
*/
return 0;

errno = err_win_to_posix(err);
return -1;
}
result = get_file_info_by_handle(hnd, buf);
Expand Down

0 comments on commit 120fb25

Please sign in to comment.