diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 08:07:01 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 08:07:01 +0000 |
| commit | a0b3c3447e832a52f64df11f2e0d69f89383faf2 (patch) | |
| tree | 9318ba139fd1c6dbcffb82ee34baf86f8214bdd4 /io.c | |
| parent | bf8885257c3b78c39bf04369025088e8a5809354 (diff) | |
| download | ruby-a0b3c3447e832a52f64df11f2e0d69f89383faf2.tar.gz ruby-a0b3c3447e832a52f64df11f2e0d69f89383faf2.tar.xz ruby-a0b3c3447e832a52f64df11f2e0d69f89383faf2.zip | |
* io.c (rb_io_initialize): check fd validity. [ruby-dev:36646]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
| -rw-r--r-- | io.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -5928,6 +5928,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); @@ -5936,6 +5937,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) |
