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

io.c (do_fcntl): update max FD for F_DUPFD_CLOEXEC, too

Somebody may pass 1030 (the value of F_DUPFD_CLOEXEC) to IO#fcntl
because they copied code from somewhere else.  Ensure we know
about FDs created that way.

* io.c (do_fcntl): update max FD for F_DUPFD_CLOEXEC, too

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2017-05-07 07:38:30 +00:00
parent a0da514102
commit b1bb2520c8

12
io.c
View file

@ -9480,11 +9480,17 @@ do_fcntl(int fd, int cmd, long narg)
arg.narg = narg;
retval = (int)rb_thread_io_blocking_region(nogvl_fcntl, &arg, fd);
if (retval != -1) {
switch (cmd) {
#if defined(F_DUPFD)
if (retval != -1 && cmd == F_DUPFD) {
rb_update_max_fd(retval);
}
case F_DUPFD:
#endif
#if defined(F_DUPFD_CLOEXEC)
case F_DUPFD_CLOEXEC:
#endif
rb_update_max_fd(retval);
}
}
return retval;
}