summaryrefslogtreecommitdiff
path: root/lib/open.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-10-11 18:23:47 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-10-11 18:24:19 -0700
commit4b60e0722d0a79751f345bd470d07db0d635aa28 (patch)
tree9ebcaa21ec5f08c0caafc7190daf34ed047f8e1f /lib/open.c
parentf9d8babe6a28b19c781778c361e45b93f7a01f17 (diff)
downloademacs-4b60e0722d0a79751f345bd470d07db0d635aa28.tar.gz
Update from Gnulib
This incorporates: 2019-10-11 Simplify and regularize regex use of ‘assert’ 2019-10-09 regex: omit debug assignment when not debugging 2019-10-09 regex: tell compiler there’s at most 256 arcs out 2019-10-09 regex: simplify by assuming C99 2019-10-09 regex: avoid copying of uninitialized storage 2019-09-29 fbufmode: Fix compilation error on glibc >= 2.28 systems 2019-09-28 Update comments that refer to POSIX 2019-09-23 Update URLs and associated text * doc/misc/texinfo.tex, lib/open.c, lib/regcomp.c: * lib/regex_internal.c, lib/regex_internal.h, lib/regexec.c: * lib/stdio-impl.h: Copy from Gnulib.
Diffstat (limited to 'lib/open.c')
-rw-r--r--lib/open.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/open.c b/lib/open.c
index 4572ebf6cd2..0c2742bbda6 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -92,9 +92,13 @@ open (const char *filename, int flags, ...)
#endif
#if OPEN_TRAILING_SLASH_BUG
- /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR
- is specified, then fail.
- Rationale: POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html>
+ /* Fail if one of O_CREAT, O_WRONLY, O_RDWR is specified and the filename
+ ends in a slash, as POSIX says such a filename must name a directory
+ <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
+ "A pathname that contains at least one non-<slash> character and that
+ ends with one or more trailing <slash> characters shall not be resolved
+ successfully unless the last pathname component before the trailing
+ <slash> characters names an existing directory"
If the named file already exists as a directory, then
- if O_CREAT is specified, open() must fail because of the semantics
of O_CREAT,
@@ -164,6 +168,12 @@ open (const char *filename, int flags, ...)
#if OPEN_TRAILING_SLASH_BUG
/* If the filename ends in a slash and fd does not refer to a directory,
then fail.
+ Rationale: POSIX says such a filename must name a directory
+ <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
+ "A pathname that contains at least one non-<slash> character and that
+ ends with one or more trailing <slash> characters shall not be resolved
+ successfully unless the last pathname component before the trailing
+ <slash> characters names an existing directory"
If the named file without the slash is not a directory, open() must fail
with ENOTDIR. */
if (fd >= 0)