diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-13 13:49:58 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-13 13:49:58 +0000 |
commit | d2fcf4249112293ebebcdcc558a93e067d33421a (patch) | |
tree | bf8d7f4a29820ba589045b2f532de6258a3a8cbd | |
parent | c3e657cdc8d23ad9547935c9a71d486089a376ae (diff) | |
download | ruby-d2fcf4249112293ebebcdcc558a93e067d33421a.tar.gz |
* ext/socket/raddrinfo.c (rsock_fd_family): Check sa_len.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | ext/socket/raddrinfo.c | 3 |
2 files changed, 6 insertions, 1 deletions
@@ -1,3 +1,7 @@ +Tue Oct 13 22:06:50 2015 Tanaka Akira <akr@fsij.org> + + * ext/socket/raddrinfo.c (rsock_fd_family): Check sa_len. + Tue Oct 13 12:14:10 2015 Craig Davison <craig65535@gmail.com> * ext/socket/rsock_addrinfo (rsock_addrinfo): specify address diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index b42707454a..5bdde2584a 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -524,7 +524,8 @@ rsock_fd_family(int fd) struct sockaddr sa = { 0 }; socklen_t sa_len = sizeof(sa); - if (fd < 0 || getsockname(fd, &sa, &sa_len) != 0) { + if (fd < 0 || getsockname(fd, &sa, &sa_len) != 0 || + sa_len < offsetof(struct sockaddr, sa_family) + sizeof(sa.sa_family)) { return AF_UNSPEC; } return sa.sa_family; |