diff --git a/ChangeLog b/ChangeLog index ca43192020..920e36c0b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Thu Oct 15 09:25:07 2009 NAKAMURA Usaku + + * 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 + + * ext/socket/init.c (rsock_init_sock): validate file descriptor. + Tue Oct 13 18:54:25 2009 Hidetoshi NAGAI * 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 #endif +#ifdef HAVE_SYS_STAT_H +#include +#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; diff --git a/version.h b/version.h index 8178e55943..6a54938076 100644 --- a/version.h +++ b/version.h @@ -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