diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 09:58:18 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 09:58:18 +0000 |
commit | 096d5338bdc7d412538d4a6f2e3847ec2c36a062 (patch) | |
tree | a0cfee1655766d17b5b9c5986767ca1265659915 /io.c | |
parent | f1f90757c40ce448a8ec43fb7dcb2ee14acbdb11 (diff) |
merges r20990 from trunk into ruby_1_9_1.
* io.c (rb_io_initialize): check fd validity. [ruby-dev:36646]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -5898,6 +5898,7 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io) int fd, fmode, oflags = O_RDONLY; convconfig_t convconfig; VALUE opt; + struct stat st; rb_secure(4); @@ -5906,6 +5907,7 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io) rb_io_extract_modeenc(&vmode, 0, opt, &oflags, &fmode, &convconfig); fd = NUM2INT(fnum); + if (fstat(fd, &st) == -1) rb_sys_fail(0); UPDATE_MAXFD(fd); if (NIL_P(vmode)) { #if defined(HAVE_FCNTL) && defined(F_GETFL) |