From 667d9ad13091559cd3888b903964ea91ba76b4de Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 27 Nov 2009 14:27:22 +0000 Subject: * fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix typos in comments. Always open file synchronized when reading header bytes, otherwise suffer stack corruption. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/fhandler_disk_file.cc | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'winsup') diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 923c578..b0daf5f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2009-11-27 Corinna Vinschen + + * fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix typos in + comments. Always open file synchronized when reading header bytes, + otherwise suffer stack corruption. + 2009-11-26 Corinna Vinschen * dtable.cc (dtable::stdio_init): Use GetCurrentProcess() rather than diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 15e4739..1ae9f9e 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -576,8 +576,8 @@ fhandler_base::fstat_helper (struct __stat64 *buf, buf->st_blocks = (buf->st_size + S_BLKSIZE - 1) / S_BLKSIZE; buf->st_mode = 0; - /* Using a side effect: get_file_attibutes checks for - directory. This is used, to set S_ISVTX, if needed. */ + /* Using a side effect: get_file_attributes checks for directory. + This is used, to set S_ISVTX, if needed. */ if (pc.isdir ()) buf->st_mode = S_IFDIR; else if (pc.issymlink ()) @@ -643,7 +643,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, || RtlEqualUnicodePathSuffix (path, &ro_u_com, TRUE)) pc.set_exec (); } - /* No known sufix, check file header. This catches binaries and + /* No known suffix, check file header. This catches binaries and shebang scripts. */ if (pc.exec_state () == dont_know_if_executable) { @@ -653,8 +653,9 @@ fhandler_base::fstat_helper (struct __stat64 *buf, InitializeObjectAttributes (&attr, &ro_u_empty, 0, get_handle (), NULL); - if (NT_SUCCESS (NtOpenFile (&h, FILE_READ_DATA, &attr, &io, - FILE_SHARE_VALID_FLAGS, 0))) + if (NT_SUCCESS (NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA, + &attr, &io, FILE_SHARE_VALID_FLAGS, + FILE_SYNCHRONOUS_IO_NONALERT))) { LARGE_INTEGER off = { QuadPart:0LL }; char magic[3]; -- cgit v1.1