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

ruby-changes:41171

From: This <ko1@a...>
Date: Tue, 22 Dec 2015 22:39:45 +0900 (JST)
Subject: [ruby-changes:41171] Re: normal:r53231 (trunk): avoid rb_bug on BasicSocket.for_fd(-1)

This test is failure with win32 environment.

http://ruby-mswin.cloudapp.net/vc10-x64/ruby-trunk/log/20151222T120215Z.log.html.gz#test-all

Can you investigate or make to skip?


On Tue, Dec 22, 2015 at 3:57 AM,  <normal@r...> wrote:
> normal  2015-12-22 03:57:50 +0900 (Tue, 22 Dec 2015)
>
>   New Revision: 53231
>
>   http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53231
>
>   Log:
>     avoid rb_bug on BasicSocket.for_fd(-1)
>
>     * 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 files:
>     trunk/ChangeLog
>     trunk/ext/socket/init.c
>     trunk/test/socket/test_basicsocket.rb



-- 
SHIBATA Hiroshi hsbt@r...
http://www.hsbt.org/
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53230)
+++ ChangeLog	(revision 53231)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Dec 22 03:57:20 2015  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]
+
 Mon Dec 21 21:29:45 2015  Naohisa Goto  <ngotogenome@g...>
 
 	* variable.c (struct ivar_update): rename "extended" to "iv_extended"
Index: ext/socket/init.c
===================================================================
--- ext/socket/init.c	(revision 53230)
+++ ext/socket/init.c	(revision 53231)
@@ -61,10 +61,10 @@ rsock_init_sock(VALUE sock, int fd) https://github.com/ruby/ruby/blob/trunk/ext/socket/init.c#L61
 {
     rb_io_t *fp;
 
-    rb_update_max_fd(fd);
     if (!is_socket(fd))
         rb_raise(rb_eArgError, "not a socket file descriptor");
 
+    rb_update_max_fd(fd);
     MakeOpenFile(sock, fp);
     fp->fd = fd;
     fp->mode = FMODE_READWRITE|FMODE_DUPLEX;
Index: test/socket/test_basicsocket.rb
===================================================================
--- test/socket/test_basicsocket.rb	(revision 53230)
+++ test/socket/test_basicsocket.rb	(revision 53231)
@@ -133,4 +133,15 @@ class TestSocket_BasicSocket < Test::Uni https://github.com/ruby/ruby/blob/trunk/test/socket/test_basicsocket.rb#L133
     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)

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

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