Revert "Cygwin: fstat_helper: always use handle in call to get_file_attribute"
This reverts commit 76dca77f04
. That
commit was based on the incorrect assumption that get_stat_handle,
when called on a FIFO in fstat_helper, would always return a handle
that is safe to use for getting the file information.
That assumption is true in many cases but not all. For example, if
the call to fstat_helper arises from a call to fstat(2) on a FIFO that
has been opened for writing, then get_stat_handle will return a pipe
handle instead of a file handle.
This commit is contained in:
parent
3192da8f80
commit
89b3833211
|
@ -394,13 +394,12 @@ fhandler_base::fstat_fs (struct stat *buf)
|
|||
return res;
|
||||
}
|
||||
|
||||
/* Called by fstat_by_handle and fstat_by_name. */
|
||||
int __reg2
|
||||
fhandler_base::fstat_helper (struct stat *buf)
|
||||
{
|
||||
IO_STATUS_BLOCK st;
|
||||
FILE_COMPRESSION_INFORMATION fci;
|
||||
HANDLE h = get_stat_handle (); /* Should always be pc.handle(). */
|
||||
HANDLE h = get_stat_handle ();
|
||||
PFILE_ALL_INFORMATION pfai = pc.fai ();
|
||||
ULONG attributes = pc.file_attributes ();
|
||||
|
||||
|
@ -476,8 +475,8 @@ fhandler_base::fstat_helper (struct stat *buf)
|
|||
else if (pc.issocket ())
|
||||
buf->st_mode = S_IFSOCK;
|
||||
|
||||
if (!get_file_attribute (h, pc, &buf->st_mode, &buf->st_uid,
|
||||
&buf->st_gid))
|
||||
if (!get_file_attribute (is_fs_special () && !pc.issocket () ? NULL : 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)
|
||||
|
|
Loading…
Reference in New Issue