summaryrefslogtreecommitdiff
path: root/ext/socket/ipsocket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-19 08:51:33 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-19 08:51:33 +0000
commit948ce9decb97e5ff0833e53a392aa9f1d42c9b0d (patch)
treeb1368f8487af5e2485608978a96aa839876a8bfb /ext/socket/ipsocket.c
parent2c36345ad633b39c51ba179fd3d0ff03d35a0618 (diff)
* ext/socket/ipsocket.c (ip_s_getaddress): Don't access freed memory.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/ipsocket.c')
-rw-r--r--ext/socket/ipsocket.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c
index 7b198bd..874c0da 100644
--- a/ext/socket/ipsocket.c
+++ b/ext/socket/ipsocket.c
@@ -305,12 +305,13 @@ ip_s_getaddress(VALUE obj, VALUE host)
{
union_sockaddr addr;
struct addrinfo *res = rsock_addrinfo(host, Qnil, SOCK_STREAM, 0);
+ socklen_t len = res->ai_addrlen;
/* just take the first one */
- memcpy(&addr, res->ai_addr, res->ai_addrlen);
+ memcpy(&addr, res->ai_addr, len);
freeaddrinfo(res);
- return rsock_make_ipaddr(&addr.addr, res->ai_addrlen);
+ return rsock_make_ipaddr(&addr.addr, len);
}
void