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

ruby-changes:41996

From: nagachika <ko1@a...>
Date: Thu, 10 Mar 2016 00:14:36 +0900 (JST)
Subject: [ruby-changes:41996] nagachika:r54070 (ruby_2_2): merge revision(s) 53677: [Backport #11877]

nagachika	2016-03-10 00:14:30 +0900 (Thu, 10 Mar 2016)

  New Revision: 54070

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

  Log:
    merge revision(s) 53677: [Backport #11877]
    
    * ext/socket/socket.c (sock_gethostname): support unlimited size
      hostname.

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/ext/socket/socket.c
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 54069)
+++ ruby_2_2/ChangeLog	(revision 54070)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Thu Mar 10 00:04:34 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/socket/socket.c (sock_gethostname): support unlimited size
+	  hostname.
+
 Wed Mar  9 22:59:43 2016  Kouhei Sutou  <kou@c...>
 
 	* lib/xmlrpc/client.rb: Support SSL options in async methods of
Index: ruby_2_2/ext/socket/socket.c
===================================================================
--- ruby_2_2/ext/socket/socket.c	(revision 54069)
+++ ruby_2_2/ext/socket/socket.c	(revision 54070)
@@ -1031,14 +1031,28 @@ sock_gethostname(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/socket/socket.c#L1031
 #  define RUBY_MAX_HOST_NAME_LEN 1024
 #endif
 
-    char buf[RUBY_MAX_HOST_NAME_LEN+1];
+    long len = RUBY_MAX_HOST_NAME_LEN;
+    VALUE name;
 
     rb_secure(3);
-    if (gethostname(buf, (int)sizeof buf - 1) < 0)
-	rb_sys_fail("gethostname(3)");
-
-    buf[sizeof buf - 1] = '\0';
-    return rb_str_new2(buf);
+    name = rb_str_new(0, len);
+    while (gethostname(RSTRING_PTR(name), len) < 0) {
+	int e = errno;
+	switch (e) {
+	  case ENAMETOOLONG:
+#ifdef __linux__
+	  case EINVAL:
+	    /* glibc before version 2.1 uses EINVAL instead of ENAMETOOLONG */
+#endif
+	    break;
+	  default:
+	    rb_syserr_fail(e, "gethostname(3)");
+	}
+	rb_str_modify_expand(name, len);
+	len += len;
+    }
+    rb_str_resize(name, strlen(RSTRING_PTR(name)));
+    return name;
 }
 #else
 #ifdef HAVE_UNAME
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 54069)
+++ ruby_2_2/version.h	(revision 54070)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.5"
-#define RUBY_RELEASE_DATE "2016-03-09"
-#define RUBY_PATCHLEVEL 253
+#define RUBY_RELEASE_DATE "2016-03-10"
+#define RUBY_PATCHLEVEL 254
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 3
-#define RUBY_RELEASE_DAY 9
+#define RUBY_RELEASE_DAY 10
 
 #include "ruby/version.h"
 

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r53677


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

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