1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

dir.c: pass flags to openat(2) correctly

Flags are 3rd argument of openat(2) while the 4th argument
(mode_t) is unnecessary for our uses.  This bug exists since
Ruby 2.5 from r58860 and was discoverd by strace.

* dir.c (nogvl_opendir_at): use openat correctly
  [Feature #13056] [Feature #14346]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2018-01-10 01:07:27 +00:00
parent 60a1dceafc
commit 7c7d47d236

4
dir.c
View file

@ -1447,7 +1447,7 @@ nogvl_opendir_at(void *ptr)
O_DIRECTORY| O_DIRECTORY|
# endif /* O_DIRECTORY */ # endif /* O_DIRECTORY */
0); 0);
int fd = openat(oaa->basefd, oaa->path, 0, opendir_flags); int fd = openat(oaa->basefd, oaa->path, opendir_flags);
dirp = fd >= 0 ? fdopendir(fd) : 0; dirp = fd >= 0 ? fdopendir(fd) : 0;
if (!dirp) { if (!dirp) {
@ -1455,7 +1455,7 @@ nogvl_opendir_at(void *ptr)
switch (gc_for_fd_with_gvl(e)) { switch (gc_for_fd_with_gvl(e)) {
default: default:
if (fd < 0) fd = openat(oaa->basefd, oaa->path, 0, opendir_flags); if (fd < 0) fd = openat(oaa->basefd, oaa->path, opendir_flags);
if (fd >= 0) dirp = fdopendir(fd); if (fd >= 0) dirp = fdopendir(fd);
if (dirp) return dirp; if (dirp) return dirp;