Cygwin: fstat_helper: always use handle in call to get_file_attribute

Previously, the call to get_file_attribute for FIFOs set the first
argument to NULL instead of the handle h returned by get_stat_handle,
thereby forcing the file to be opened for fetching the security
descriptor in get_file_sd().  This was done because h might have been
a pipe handle rather than a file handle, and its permissions would not
necessarily reflect those of the file.

That situation can no longer occur with the new fhandler_fifo::fstat
introduced in the previous commit.
This commit is contained in:
Ken Brown 2021-02-10 21:15:20 -05:00
parent e67679fcac
commit 70f6360869
1 changed files with 1 additions and 2 deletions

View File

@ -475,8 +475,7 @@ fhandler_base::fstat_helper (struct stat *buf)
else if (pc.issocket ())
buf->st_mode = S_IFSOCK;
if (!get_file_attribute (is_fs_special () && !pc.issocket () ? NULL : h, pc,
&buf->st_mode, &buf->st_uid, &buf->st_gid))
if (!get_file_attribute (h, pc, &buf->st_mode, &buf->st_uid, &buf->st_gid))
{
/* If read-only attribute is set, modify ntsec return value */
if (::has_attribute (attributes, FILE_ATTRIBUTE_READONLY)