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 | dbd5b8c534cda863c62d39858d57f738f4332c52 (patch) | |
| tree | a0cfee1655766d17b5b9c5986767ca1265659915 | |
| parent | 7fed8bd7140edbfbe6aca3e3b8f6bcd880a4d842 (diff) | |
merges r20990 from trunk into ruby_1_9_1.
* io.c (rb_io_initialize): check fd validity. [ruby-dev:36646]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | io.c | 2 |
2 files changed, 6 insertions, 0 deletions
@@ -1,3 +1,7 @@ +Thu Dec 25 17:06:13 2008 Tanaka Akira <akr@fsij.org> + + * io.c (rb_io_initialize): check fd validity. [ruby-dev:36646] + Thu Dec 25 16:23:31 2008 Tanaka Akira <akr@fsij.org> * io.c (flush_before_seek): check io_fflush result. @@ -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) |
