]> Savannah Git Hosting - gnulib.git/commitdiff
openat: Fix theoretically possible issue on GNU/Hurd.
authorBruno Haible <bruno@clisp.org>
Sat, 7 Mar 2020 17:35:25 +0000 (18:35 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 7 Mar 2020 17:35:25 +0000 (18:35 +0100)
Reported by Dan Gohman <sunfish@mozilla.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-03/msg00000.html>.

* lib/openat.c (rpl_openat): When testing whether flags contains O_RDWR,
ignore the bits that are also set in O_RDONLY.

ChangeLog
lib/openat.c

index 067e41956fa69e2364030465e5fc4f49a46f27d2..8414234c0e9c800944309235c1172ef7ad937b7b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-03-07  Bruno Haible  <bruno@clisp.org>
+
+       openat: Fix theoretically possible issue on GNU/Hurd.
+       Reported by Dan Gohman <sunfish@mozilla.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2020-03/msg00000.html>.
+       * lib/openat.c (rpl_openat): When testing whether flags contains O_RDWR,
+       ignore the bits that are also set in O_RDONLY.
+
 2020-02-24  Bruno Haible  <bruno@clisp.org>
 
        getloadavg: Don't use /usr/local when cross-compiling on AIX.
index d2c84e8f80489201be2a7198bb979fe4be6f9ecb..7d67dc4cad1065929943384669507372b44a48e1 100644 (file)
@@ -100,7 +100,7 @@ rpl_openat (int dfd, char const *filename, int flags, ...)
          directories,
        - if O_WRONLY or O_RDWR is specified, open() must fail because the
          file does not contain a '.' directory.  */
-  if (flags & (O_CREAT | O_WRONLY | O_RDWR))
+  if (flags & (O_CREAT | O_WRONLY | (O_RDWR & ~O_RDONLY)))
     {
       size_t len = strlen (filename);
       if (len > 0 && filename[len - 1] == '/')