diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-21 18:57:50 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-21 18:57:50 +0000 |
commit | e5feaa1107c15ca269e23ece182ff8cc7102519b (patch) | |
tree | 5e9846ac54992b4e1165890dd16b70ccf03bf240 /test/socket | |
parent | 5b28eebc556d1c9a2a414f57d6d64c5ebd3a4e8d (diff) | |
download | ruby-e5feaa1107c15ca269e23ece182ff8cc7102519b.tar.gz |
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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket')
-rw-r--r-- | test/socket/test_basicsocket.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/socket/test_basicsocket.rb b/test/socket/test_basicsocket.rb index 227034ed26..52732f18f6 100644 --- a/test/socket/test_basicsocket.rb +++ b/test/socket/test_basicsocket.rb @@ -133,4 +133,15 @@ class TestSocket_BasicSocket < Test::Unit::TestCase 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) |