From: Eric Blake <ebb9@byu.net>
Date: Sat, 3 Oct 2009 04:41:54 +0000 (-0600)
Subject: open: fix opening directory on mingw
X-Git-Tag: v0.1~5381
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=14b6206605af50774bc0202b7cbcce9418f8ede5;p=gnulib.git

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>
---

diff --git a/ChangeLog b/ChangeLog
index 3ef349e998..df080c8bb1 100644
--- 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
diff --git a/lib/open.c b/lib/open.c
index 7cc25bd07c..8027b473a5 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -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))