[前][次][番号順一覧][スレッド一覧]

ruby-changes:32966

From: akr <ko1@a...>
Date: Wed, 19 Feb 2014 17:51:37 +0900 (JST)
Subject: [ruby-changes:32966] akr:r45045 (trunk): * ext/socket/ipsocket.c (ip_s_getaddress): Don't access freed memory.

akr	2014-02-19 17:51:33 +0900 (Wed, 19 Feb 2014)

  New Revision: 45045

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45045

  Log:
    * ext/socket/ipsocket.c (ip_s_getaddress): Don't access freed memory.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/ipsocket.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45044)
+++ ChangeLog	(revision 45045)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Feb 19 17:47:01 2014  Tanaka Akira  <akr@f...>
+
+	* ext/socket/ipsocket.c (ip_s_getaddress): Don't access freed memory.
+
 Wed Feb 19 11:39:41 2014  NARUSE, Yui  <naruse@r...>
 
 	* configure.in: it must see rb_cv_broken_memmem not rb_cv_func_memmem.
Index: ext/socket/ipsocket.c
===================================================================
--- ext/socket/ipsocket.c	(revision 45044)
+++ ext/socket/ipsocket.c	(revision 45045)
@@ -305,12 +305,13 @@ ip_s_getaddress(VALUE obj, VALUE host) https://github.com/ruby/ruby/blob/trunk/ext/socket/ipsocket.c#L305
 {
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]