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

ruby-changes:40038

From: akr <ko1@a...>
Date: Tue, 13 Oct 2015 22:50:20 +0900 (JST)
Subject: [ruby-changes:40038] akr:r52119 (trunk): * ext/socket/raddrinfo.c (rsock_fd_family): Check sa_len.

akr	2015-10-13 22:49:58 +0900 (Tue, 13 Oct 2015)

  New Revision: 52119

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

  Log:
    * ext/socket/raddrinfo.c (rsock_fd_family): Check sa_len.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/raddrinfo.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52118)
+++ ChangeLog	(revision 52119)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct 13 22:06:50 2015  Tanaka Akira  <akr@f...>
+
+	* ext/socket/raddrinfo.c (rsock_fd_family): Check sa_len.
+
 Tue Oct 13 12:14:10 2015  Craig Davison  <craig65535@g...>
 
 	* ext/socket/rsock_addrinfo (rsock_addrinfo): specify address
Index: ext/socket/raddrinfo.c
===================================================================
--- ext/socket/raddrinfo.c	(revision 52118)
+++ ext/socket/raddrinfo.c	(revision 52119)
@@ -524,7 +524,8 @@ rsock_fd_family(int fd) https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L524
     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;

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

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