diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-30 12:47:55 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-30 12:47:55 +0000 |
commit | 4fe744b10706a62196957d1d9c45e1f63f9dfdd9 (patch) | |
tree | 9e5a28bafe4b6753714f0c3e94a06347c54916f3 | |
parent | 7e0875aa161a6d83bf89d9a6a20f835fbb1c578f (diff) |
merges r25336 and r25339 from trunk into ruby_1_9_1.
--
* ext/socket/init.c (rsock_init_sock): validate file descriptor.
--
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@26486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-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 |