From a99ca2e041127e0c0d6c14273097c86879a6ebe3 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 7 Mar 2020 18:35:25 +0100 Subject: [PATCH] openat: Fix theoretically possible issue on GNU/Hurd. Reported by Dan Gohman in . * lib/openat.c (rpl_openat): When testing whether flags contains O_RDWR, ignore the bits that are also set in O_RDONLY. --- ChangeLog | 8 ++++++++ lib/openat.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 067e41956f..8414234c0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2020-03-07 Bruno Haible + + openat: Fix theoretically possible issue on GNU/Hurd. + Reported by Dan Gohman in + . + * 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 getloadavg: Don't use /usr/local when cross-compiling on AIX. diff --git a/lib/openat.c b/lib/openat.c index d2c84e8f80..7d67dc4cad 100644 --- a/lib/openat.c +++ b/lib/openat.c @@ -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] == '/') -- 2.39.5