mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
3bf3f825c3
commit
409e53dec1
3 changed files with 18 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
Tue Dec 22 03:57:20 2015 Eric Wong <e@80x24.org>
|
||||
|
||||
* 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@gmail.com>
|
||||
|
||||
* variable.c (struct ivar_update): rename "extended" to "iv_extended"
|
||||
|
|
|
@ -61,10 +61,10 @@ rsock_init_sock(VALUE sock, int fd)
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue