From b1bb2520c80186cf18d44574cf1b204d1560f02f Mon Sep 17 00:00:00 2001 From: normal Date: Sun, 7 May 2017 07:38:30 +0000 Subject: [PATCH] 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 --- io.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/io.c b/io.c index 9f6c2fe871..c274c9b9fe 100644 --- a/io.c +++ b/io.c @@ -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; }