diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | ext/socket/socket.c | 14 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 25 insertions, 1 deletions
@@ -1,3 +1,13 @@ +Thu Oct 15 09:25:07 2009 NAKAMURA Usaku <usa@ruby-lang.org> + + * ext/socket/init.c (rsock_init_sock): mswin doesn't have S_IFSOCK + flag in st_mode of struct stat. so, use rb_w32_issocket() function + instead of S_ISSOCK macro. + +Thu Oct 15 00:26:07 2009 Tanaka Akira <akr@fsij.org> + + * ext/socket/init.c (rsock_init_sock): validate file descriptor. + Tue Oct 13 18:54:25 2009 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> * ext/tk/variable.rb: bug fix. additional trace definition changes the diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 73a02d15f3..a7c5948b69 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -52,6 +52,9 @@ #ifdef HAVE_SYS_UN_H #include <sys/un.h> #endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif #if defined(HAVE_FCNTL) #ifdef HAVE_SYS_SELECT_H @@ -237,6 +240,17 @@ static VALUE init_sock(VALUE sock, int fd) { rb_io_t *fp; + struct stat sbuf; + +#ifndef _WIN32 + if (fstat(fd, &sbuf) < 0) + rb_sys_fail(0); + if (!S_ISSOCK(sbuf.st_mode)) + rb_raise(rb_eArgError, "not a socket file descriptor"); +#else + if (!rb_w32_is_socket(fd)) + rb_raise(rb_eArgError, "not a socket file descriptor"); +#endif MakeOpenFile(sock, fp); fp->fd = fd; @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.1" -#define RUBY_PATCHLEVEL 391 +#define RUBY_PATCHLEVEL 392 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 |