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 | 409e53dec17a725dfa9963ad7d907185bbb208fb (patch) | |
tree | 5e9846ac54992b4e1165890dd16b70ccf03bf240 /ext/socket | |
parent | 3bf3f825c3fee660fd50ef9d7f3f69c8f58b106d (diff) | |
download | ruby-409e53dec17a725dfa9963ad7d907185bbb208fb.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 'ext/socket')
-rw-r--r-- | ext/socket/init.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ext/socket/init.c b/ext/socket/init.c index d0711025a5..bd069263c6 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -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; |