* win32/win32.c (rb_w32_read, rb_w32_write, rb_w32_isatty): check
whether fd is valid. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f6d18c3f2a
commit
5d65e0982d
@ -1,3 +1,8 @@
|
||||
Fri Dec 5 18:07:32 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* 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@ruby-lang.org>
|
||||
|
||||
* iseq.c (rb_iseq_parameters): proc arguments are always optional.
|
||||
|
@ -4316,6 +4316,10 @@ rb_w32_read(int fd, void *buf, size_t size)
|
||||
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 @@ rb_w32_write(int fd, const void *buf, size_t size)
|
||||
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 @@ rb_w32_unlink(const char *path)
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user