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

ruby-changes:33941

From: akr <ko1@a...>
Date: Mon, 19 May 2014 23:28:41 +0900 (JST)
Subject: [ruby-changes:33941] akr:r46022 (trunk): * ext/socket/option.c (inspect_tcp_info): Permit longer data. (glibc

akr	2014-05-19 23:28:26 +0900 (Mon, 19 May 2014)

  New Revision: 46022

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

  Log:
    * ext/socket/option.c (inspect_tcp_info): Permit longer data.  (glibc
      2.7 adds tcpi_rcv_rtt, tcpi_rcv_space and tcpi_total_retrans to
      struct tcp_info.)

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/option.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46021)
+++ ChangeLog	(revision 46022)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon May 19 23:13:33 2014  Tanaka Akira  <akr@f...>
+
+	* ext/socket/option.c (inspect_tcp_info): Permit longer data.  (glibc
+	  2.7 adds tcpi_rcv_rtt, tcpi_rcv_space and tcpi_total_retrans to
+	  struct tcp_info.)
+
 Mon May 19 20:49:07 2014  Tanaka Akira  <akr@f...>
 
 	* ext/socket/option.c (inspect_tcp_info): New function to inspect
Index: ext/socket/option.c
===================================================================
--- ext/socket/option.c	(revision 46021)
+++ ext/socket/option.c	(revision 46022)
@@ -920,7 +920,8 @@ inspect_tcpi_msec(VALUE ret, const char https://github.com/ruby/ruby/blob/trunk/ext/socket/option.c#L920
 static int
 inspect_tcp_info(int level, int optname, VALUE data, VALUE ret)
 {
-    if (RSTRING_LEN(data) == sizeof(struct tcp_info)) {
+    size_t actual_size = RSTRING_LEN(data);
+    if (sizeof(struct tcp_info) <= actual_size) {
         struct tcp_info s;
         memcpy((char*)&s, RSTRING_PTR(data), sizeof(s));
 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_STATE
@@ -1063,6 +1064,8 @@ inspect_tcp_info(int level, int optname, https://github.com/ruby/ruby/blob/trunk/ext/socket/option.c#L1064
 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_ZEROWIN
         rb_str_catf(ret, " snd_zerowin=%u", s.tcpi_snd_zerowin); /* FreeBSD */
 #endif
+        if (sizeof(struct tcp_info) < actual_size)
+            rb_str_catf(ret, " (%u bytes too long)", (unsigned)(actual_size - sizeof(struct tcp_info)));
         return 1;
     }
     else {

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

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