ruby-changes:9003
From: usa <ko1@a...>
Date: Fri, 5 Dec 2008 18:08:50 +0900 (JST)
Subject: [ruby-changes:9003] Ruby:r20539 (trunk): * win32/win32.c (rb_w32_read, rb_w32_write, rb_w32_isatty): check
usa 2008-12-05 18:08:24 +0900 (Fri, 05 Dec 2008) New Revision: 20539 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20539 Log: * win32/win32.c (rb_w32_read, rb_w32_write, rb_w32_isatty): check whether fd is valid. Modified files: trunk/ChangeLog trunk/win32/win32.c Index: ChangeLog =================================================================== --- ChangeLog (revision 20538) +++ ChangeLog (revision 20539) @@ -1,3 +1,8 @@ +Fri Dec 5 18:07:32 2008 NAKAMURA Usaku <usa@r...> + + * win32/win32.c (rb_w32_read, rb_w32_write, rb_w32_isatty): check + whether fd is valid. + Fri Dec 5 13:05:45 2008 Nobuyoshi Nakada <nobu@r...> * iseq.c (rb_iseq_parameters): proc arguments are always optional. Index: win32/win32.c =================================================================== --- win32/win32.c (revision 20538) +++ win32/win32.c (revision 20539) @@ -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; @@ -4434,6 +4438,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; @@ -4686,6 +4694,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/