# HG changeset patch # User Eric Blake # Date 1254544914 21600 # Node ID 5f350c5819bdc9a70244ae5b2fcc51b29fdc2fec # Parent edba99785b759d24c657a09e78c3b3eb8272977e 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 diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-10-02 Eric Blake + 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 --- 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))