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

ruby-changes:41849

From: usa <ko1@a...>
Date: Thu, 25 Feb 2016 17:44:32 +0900 (JST)
Subject: [ruby-changes:41849] usa:r53923 (ruby_2_1): merge revision(s) 53231, 53244: [Backport #11854]

usa	2016-02-25 17:45:12 +0900 (Thu, 25 Feb 2016)

  New Revision: 53923

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53923

  Log:
    merge revision(s) 53231,53244: [Backport #11854]
    
    * ext/socket/init.c (rsock_init_sock): check FD after validating
    
    * test/socket/test_basicsocket.rb (test_for_fd): new
      [ruby-core:72418] [Bug #11854]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/ext/socket/init.c
    branches/ruby_2_1/test/socket/test_basicsocket.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ext/socket/init.c
===================================================================
--- ruby_2_1/ext/socket/init.c	(revision 53922)
+++ ruby_2_1/ext/socket/init.c	(revision 53923)
@@ -48,15 +48,18 @@ rsock_init_sock(VALUE sock, int fd) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ext/socket/init.c#L48
 
     if (fstat(fd, &sbuf) < 0)
         rb_sys_fail("fstat(2)");
-    rb_update_max_fd(fd);
-    if (!S_ISSOCK(sbuf.st_mode))
-        rb_raise(rb_eArgError, "not a socket file descriptor");
+    if (!S_ISSOCK(sbuf.st_mode)) {
+	errno = EBADF;
+        rb_sys_fail("not a socket file descriptor");
+    }
 #else
-    rb_update_max_fd(fd);
-    if (!rb_w32_is_socket(fd))
-        rb_raise(rb_eArgError, "not a socket file descriptor");
+    if (!rb_w32_is_socket(fd)) {
+	errno = EBADF;
+        rb_sys_fail("not a socket file descriptor");
+    }
 #endif
 
+    rb_update_max_fd(fd);
     MakeOpenFile(sock, fp);
     fp->fd = fd;
     fp->mode = FMODE_READWRITE|FMODE_DUPLEX;
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 53922)
+++ ruby_2_1/ChangeLog	(revision 53923)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Thu Feb 25 17:38:59 2016  Eric Wong  <e@8...>
+
+	* ext/socket/init.c (rsock_init_sock): check FD after validating
+	* test/socket/test_basicsocket.rb (test_for_fd): new
+	  [ruby-core:72418] [Bug #11854]
+
 Thu Feb 25 17:33:38 2016  SHIBATA Hiroshi  <hsbt@r...>
 
 	* cont.c: fix a double word typo.
Index: ruby_2_1/test/socket/test_basicsocket.rb
===================================================================
--- ruby_2_1/test/socket/test_basicsocket.rb	(revision 53922)
+++ ruby_2_1/test/socket/test_basicsocket.rb	(revision 53923)
@@ -85,4 +85,15 @@ class TestSocket_BasicSocket < Test::Uni https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/socket/test_basicsocket.rb#L85
       }
     end
   end
+  def test_for_fd
+    assert_raise(Errno::EBADF, '[ruby-core:72418] [Bug #11854]') do
+      BasicSocket.for_fd(-1)
+    end
+    inet_stream do |sock|
+      s = BasicSocket.for_fd(sock.fileno)
+      assert_instance_of BasicSocket, s
+      s.autoclose = false
+      sock.close
+    end
+  end
 end if defined?(BasicSocket)
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 53922)
+++ ruby_2_1/version.h	(revision 53923)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.9"
 #define RUBY_RELEASE_DATE "2016-02-25"
-#define RUBY_PATCHLEVEL 444
+#define RUBY_PATCHLEVEL 445
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 2

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r53231,53244


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

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