changeset 12106:5f350c5819bd

open: fix opening directory on mingw open(".",O_WRONLY) used uninitialized memory to decide whether to succeed or fail - never a good idea ;) * lib/open.c (open) [REPLACE_OPEN_DIRECTORY]: Correct typo. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Fri, 02 Oct 2009 22:41:54 -0600
parents edba99785b75
children 90198e1c7821
files ChangeLog lib/open.c
diffstat 2 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-10-02  Eric Blake  <ebb9@byu.net>
 
+	open: fix opening directory on mingw
+	* lib/open.c (open) [REPLACE_OPEN_DIRECTORY]: Correct typo.
+
 	test-open: on GNU/Hurd, /dev/null is a directory
 	* tests/test-fopen.h (main): Rename...
 	(test_fopen): ...to this.  Use a guaranteed non-directory when
--- a/lib/open.c
+++ b/lib/open.c
@@ -111,7 +111,7 @@
      override fstat() in fchdir.c to hide the fact that we have a
      dummy.  */
   if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES
-      && (mode & O_ACCMODE) == O_RDONLY)
+      && (flags & O_ACCMODE) == O_RDONLY)
     {
       struct stat statbuf;
       if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))