summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog4
-rw-r--r--ext/socket/ipsocket.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index e6e8ce9a9e..190a6c8a29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Feb 19 17:47:01 2014 Tanaka Akira <akr@fsij.org>
+
+ * ext/socket/ipsocket.c (ip_s_getaddress): Don't access freed memory.
+
Wed Feb 19 11:39:41 2014 NARUSE, Yui <naruse@ruby-lang.org>
* configure.in: it must see rb_cv_broken_memmem not rb_cv_func_memmem.
diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c
index 7b198bd154..874c0da3e5 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