diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-14 15:26:40 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-14 15:26:40 +0000 |
commit | 05eb30494760d1723d8fe18d902cdb9f8b9a5ab1 (patch) | |
tree | 0b9287505c1d77eb35d603a20a08447582bafd13 /ext/socket | |
parent | b97494f3cb8032433039adff3d9bc45bc83256c3 (diff) | |
download | ruby-05eb30494760d1723d8fe18d902cdb9f8b9a5ab1.tar.gz |
* ext/socket/init.c (rsock_init_sock): validate file descriptor.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/init.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/socket/init.c b/ext/socket/init.c index ed85e0b503..85cc3de4f9 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -43,6 +43,12 @@ VALUE rsock_init_sock(VALUE sock, int fd) { rb_io_t *fp; + struct stat sbuf; + + if (fstat(fd, &sbuf) < 0) + rb_sys_fail(0); + if (!S_ISSOCK(sbuf.st_mode)) + rb_raise(rb_eArgError, "not a socket file descriptor"); MakeOpenFile(sock, fp); fp->fd = fd; |