* io.c (rb_io_initialize): check fd validity. [ruby-dev:36646]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-12-25 08:07:01 +00:00
parent db0a659012
commit ea6ac1c45b
2 changed files with 6 additions and 0 deletions

View File

@ -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> Thu Dec 25 16:23:31 2008 Tanaka Akira <akr@fsij.org>
* io.c (flush_before_seek): check io_fflush result. * io.c (flush_before_seek): check io_fflush result.

2
io.c
View File

@ -5928,6 +5928,7 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
int fd, fmode, oflags = O_RDONLY; int fd, fmode, oflags = O_RDONLY;
convconfig_t convconfig; convconfig_t convconfig;
VALUE opt; VALUE opt;
struct stat st;
rb_secure(4); 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); rb_io_extract_modeenc(&vmode, 0, opt, &oflags, &fmode, &convconfig);
fd = NUM2INT(fnum); fd = NUM2INT(fnum);
if (fstat(fd, &st) == -1) rb_sys_fail(0);
UPDATE_MAXFD(fd); UPDATE_MAXFD(fd);
if (NIL_P(vmode)) { if (NIL_P(vmode)) {
#if defined(HAVE_FCNTL) && defined(F_GETFL) #if defined(HAVE_FCNTL) && defined(F_GETFL)