Mercurial > hg > octave-lojdl > gnulib-hg
changeset 11939:cd48f861a7a7
fts: make directory fds more robust
* lib/fts.c (O_DIRECTORY): Let <fcntl.h> take care of this.
(opendirat): Specify O_DIRECTORY, and add fallbacks for safety.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Tue, 01 Sep 2009 14:06:37 -0600 |
parents | 7cbcde229d97 |
children | 6dd8c8815b1f |
files | ChangeLog lib/fts.c |
diffstat | 2 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-09-02 Eric Blake <ebb9@byu.net> + fts: make directory fds more robust + * lib/fts.c (O_DIRECTORY): Let <fcntl.h> take care of this. + (opendirat): Specify O_DIRECTORY, and add fallbacks for safety. + backupfile, chdir-long, fts, savedir: make safer * lib/backupfile.c (includes): Use "dirent--.h", since numbered_backup can write to stderr during readdir.
--- a/lib/fts.c +++ b/lib/fts.c @@ -228,10 +228,6 @@ # define SIZE_MAX ((size_t) -1) #endif -#ifndef O_DIRECTORY -# define O_DIRECTORY 0 -#endif - #define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) #define STREQ(a, b) (strcmp ((a), (b)) == 0) @@ -309,7 +305,8 @@ internal_function opendirat (int fd, char const *dir) { - int new_fd = openat (fd, dir, O_RDONLY); + int new_fd = openat (fd, dir, + O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); DIR *dirp; if (new_fd < 0)