OSDN Git Service

* fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix typos in
authorcorinna <corinna>
Fri, 27 Nov 2009 23:27:22 +0000 (23:27 +0000)
committercorinna <corinna>
Fri, 27 Nov 2009 23:27:22 +0000 (23:27 +0000)
comments.  Always open file synchronized when reading header bytes,
otherwise suffer stack corruption.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_disk_file.cc

index 923c578..b0daf5f 100644 (file)
@@ -1,3 +1,9 @@
+2009-11-27  Corinna Vinschen  <corinna@vinschen.de>
+
+       * 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  <corinna@vinschen.de>
 
        * dtable.cc (dtable::stdio_init): Use GetCurrentProcess() rather than
index 15e4739..1ae9f9e 100644 (file)
@@ -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];