open: fix opening directory on mingw
authorEric Blake <ebb9@byu.net>
Sat, 3 Oct 2009 04:41:54 +0000 (22:41 -0600)
committerEric Blake <ebb9@byu.net>
Sat, 3 Oct 2009 04:46:07 +0000 (22:46 -0600)
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>
ChangeLog
lib/open.c

index 3ef349e..df080c8 100644 (file)
--- 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
index 7cc25bd..8027b47 100644 (file)
@@ -111,7 +111,7 @@ open (const char *filename, int flags, ...)
      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))