summaryrefslogtreecommitdiff
path: root/ext/socket/raddrinfo.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-13 13:49:58 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-13 13:49:58 +0000
commite794fa5cb5b2a2ebffa4a535da4d951f6a4b559a (patch)
treebf8d7f4a29820ba589045b2f532de6258a3a8cbd /ext/socket/raddrinfo.c
parent33f3789e852080cc6b681748f56bd29f7a555b22 (diff)
* 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
Diffstat (limited to 'ext/socket/raddrinfo.c')
-rw-r--r--ext/socket/raddrinfo.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index b4270745..5bdde25 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;