ruby-changes:9005
From: usa <ko1@a...>
Date: Fri, 5 Dec 2008 18:14:52 +0900 (JST)
Subject: [ruby-changes:9005] Ruby:r20540 (ruby_1_8, ruby_1_9_1): * win32/win32.c (rb_w32_read, rb_w32_write, rb_w32_isatty): check
usa 2008-12-05 18:14:12 +0900 (Fri, 05 Dec 2008) New Revision: 20540 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20540 Log: * win32/win32.c (rb_w32_read, rb_w32_write, rb_w32_isatty): check whether fd is valid. Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/win32/win32.c branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/win32/win32.c Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 20539) +++ ruby_1_8/ChangeLog (revision 20540) @@ -1,3 +1,7 @@ +Fri Dec 5 18:13:39 2008 NAKAMURA Usaku <usa@r...> + + * win32/win32.c (rb_w32_isatty): check whether fd is valid. + Fri Dec 5 12:49:24 2008 NAKAMURA Usaku <usa@r...> * win32/win32.c (waitpid): fix bug of checking child slot. Index: ruby_1_8/win32/win32.c =================================================================== --- ruby_1_8/win32/win32.c (revision 20539) +++ ruby_1_8/win32/win32.c (revision 20540) @@ -4091,6 +4091,10 @@ int rb_w32_isatty(int fd) { + // validate fd by using _get_osfhandle() because we cannot access _nhandle + if (_get_osfhandle(fd) == -1) { + return 0; + } if (!(_osfile(fd) & FOPEN)) { errno = EBADF; return 0; Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 20539) +++ ruby_1_9_1/ChangeLog (revision 20540) @@ -1,3 +1,8 @@ +Fri Dec 5 18:13:56 2008 NAKAMURA Usaku <usa@r...> + + * win32/win32.c (rb_w32_read, rb_w32_write, rb_w32_isatty): check + whether fd is valid. + Thu Dec 4 23:31:12 2008 NAKAMURA Usaku <usa@r...> * win32/win32.c (waitpid): fix bug of checking child slot. Index: ruby_1_9_1/win32/win32.c =================================================================== --- ruby_1_9_1/win32/win32.c (revision 20539) +++ ruby_1_9_1/win32/win32.c (revision 20540) @@ -4316,6 +4316,10 @@ if (is_socket(sock)) return rb_w32_recv(fd, buf, size, 0); + // validate fd by using _get_osfhandle() because we cannot access _nhandle + if (_get_osfhandle(fd) == -1) { + return -1; + } if (!(_osfile(fd) & FOPEN)) { errno = EBADF; return -1; @@ -4430,6 +4434,10 @@ if (is_socket(sock)) return rb_w32_send(fd, buf, size, 0); + // validate fd by using _get_osfhandle() because we cannot access _nhandle + if (_get_osfhandle(fd) == -1) { + return -1; + } if (!(_osfile(fd) & FOPEN)) { errno = EBADF; return -1; @@ -4682,6 +4690,10 @@ int rb_w32_isatty(int fd) { + // validate fd by using _get_osfhandle() because we cannot access _nhandle + if (_get_osfhandle(fd) == -1) { + return 0; + } if (!(_osfile(fd) & FOPEN)) { errno = EBADF; return 0; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/