aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-18 00:22:04 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-18 00:22:04 +0000
commitf0d9889b4066185dab2d15a97b3aab6c345a570f (patch)
treeb317c8bfb12f26d3bc02961f2b89f81da838e8b1 /ext
parent7277898d38620116308caf45cd047f2e2b2ca97c (diff)
downloadruby-f0d9889b4066185dab2d15a97b3aab6c345a570f.tar.gz
pty.c: more difensive
* ext/pty/pty.c (chfunc): should not close the slave fd if it is 0..2. [ruby-core:89043] [Bug #15116] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/pty/pty.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 1a70bf7b61..33e727e765 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -143,7 +143,7 @@ chfunc(void *data, char *errbuf, size_t errbuf_len)
dup2(slave,0);
dup2(slave,1);
dup2(slave,2);
- close(slave);
+ if (slave < 0 && slave > 2) (void)!close(slave);
#if defined(HAVE_SETEUID) || defined(HAVE_SETREUID) || defined(HAVE_SETRESUID)
if (seteuid(getuid())) ERROR_EXIT("seteuid()");
#endif
@@ -233,7 +233,7 @@ ioctl_I_PUSH(int fd, const char *const name)
ret = ioctl(fd, I_FIND, name);
# endif
if (ret == 0) {
- ret = ioctl(fd, I_PUSH, name);
+ ret = ioctl(fd, I_PUSH, name);
}
return ret;
}