[前][次][番号順一覧][スレッド一覧]

ruby-changes:14641

From: yugui <ko1@a...>
Date: Sat, 30 Jan 2010 21:48:12 +0900 (JST)
Subject: [ruby-changes:14641] Ruby:r26486 (ruby_1_9_1): merges r25336 and r25339 from trunk into ruby_1_9_1.

yugui	2010-01-30 21:47:55 +0900 (Sat, 30 Jan 2010)

  New Revision: 26486

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26486

  Log:
    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.

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/ext/socket/socket.c
    branches/ruby_1_9_1/version.h

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 26485)
+++ ruby_1_9_1/ChangeLog	(revision 26486)
@@ -1,3 +1,13 @@
+Thu Oct 15 09:25:07 2009  NAKAMURA Usaku  <usa@r...>
+
+ * 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@f...>
+
+	* ext/socket/init.c (rsock_init_sock): validate file descriptor.
+
 Tue Oct 13 18:54:25 2009  Hidetoshi NAGAI  <nagai@a...>
 
 	* ext/tk/variable.rb: bug fix. additional trace definition changes the
Index: ruby_1_9_1/ext/socket/socket.c
===================================================================
--- ruby_1_9_1/ext/socket/socket.c	(revision 26485)
+++ ruby_1_9_1/ext/socket/socket.c	(revision 26486)
@@ -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 @@
 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;
Index: ruby_1_9_1/version.h
===================================================================
--- ruby_1_9_1/version.h	(revision 26485)
+++ ruby_1_9_1/version.h	(revision 26486)
@@ -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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]