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

ruby-changes:27042

From: usa <ko1@a...>
Date: Wed, 6 Feb 2013 14:25:09 +0900 (JST)
Subject: [ruby-changes:27042] usa:r39094 (ruby_1_9_3): merge revision(s) 38993: [Backport #7775]

usa	2013-02-06 14:21:33 +0900 (Wed, 06 Feb 2013)

  New Revision: 39094

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

  Log:
    merge revision(s) 38993: [Backport #7775]
    
    * ext/socket/basicsocket.c (bsock_getsockname): ignore truncated
      part of socket address.
      (bsock_getpeername): ditto.
      (bsock_local_address): ditto.
      (bsock_remote_address): ditto.
    
    * ext/socket/unixsocket.c (unix_path): ditto.
      (unix_addr): ditto.
      (unix_peeraddr): ditto.
    
    * ext/socket/init.c (cloexec_accept): ditto.

  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/ext/socket/basicsocket.c
    branches/ruby_1_9_3/ext/socket/init.c
    branches/ruby_1_9_3/ext/socket/unixsocket.c
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 39093)
+++ ruby_1_9_3/ChangeLog	(revision 39094)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Wed Feb  6 14:20:12 2013  Tanaka Akira  <akr@f...>
+
+	* ext/socket/basicsocket.c (bsock_getsockname): ignore truncated
+	  part of socket address.
+	  (bsock_getpeername): ditto.
+	  (bsock_local_address): ditto.
+	  (bsock_remote_address): ditto.
+
+	* ext/socket/unixsocket.c (unix_path): ditto.
+	  (unix_addr): ditto.
+	  (unix_peeraddr): ditto.
+
+	* ext/socket/init.c (cloexec_accept): ditto.
+
 Wed Feb  6 14:19:07 2013  Kouhei Sutou  <kou@c...>
 
 	* lib/rexml/parsers/baseparser.rb, test/rexml/test_comment.rb:
Index: ruby_1_9_3/ext/socket/init.c
===================================================================
--- ruby_1_9_3/ext/socket/init.c	(revision 39093)
+++ ruby_1_9_3/ext/socket/init.c	(revision 39094)
@@ -448,6 +448,7 @@ VALUE https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/socket/init.c#L448
 rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len)
 {
     int fd2;
+    socklen_t len0 = len ? *len : 0;
 
     rb_secure(3);
     rb_io_set_nonblock(fptr);
@@ -466,6 +467,7 @@ rsock_s_accept_nonblock(VALUE klass, rb_ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/socket/init.c#L467
 	}
         rb_sys_fail("accept(2)");
     }
+    if (len && len0 < *len) *len = len0;
     rb_update_max_fd(fd2);
     make_fd_nonblock(fd2);
     return rsock_init_sock(rb_obj_alloc(klass), fd2);
@@ -481,7 +483,12 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/socket/init.c#L483
 accept_blocking(void *data)
 {
     struct accept_arg *arg = data;
-    return (VALUE)accept(arg->fd, arg->sockaddr, arg->len);
+    int ret;
+    socklen_t len0 = 0;
+    if (arg->len) len0 = *arg->len;
+    ret = accept(arg->fd, arg->sockaddr, arg->len);
+    if (arg->len && len0 < *arg->len) *arg->len = len0;
+    return (VALUE)ret;
 }
 
 VALUE
Index: ruby_1_9_3/ext/socket/basicsocket.c
===================================================================
--- ruby_1_9_3/ext/socket/basicsocket.c	(revision 39093)
+++ ruby_1_9_3/ext/socket/basicsocket.c	(revision 39094)
@@ -358,11 +358,13 @@ bsock_getsockname(VALUE sock) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/socket/basicsocket.c#L358
 {
     struct sockaddr_storage buf;
     socklen_t len = (socklen_t)sizeof buf;
+    socklen_t len0 = len;
     rb_io_t *fptr;
 
     GetOpenFile(sock, fptr);
     if (getsockname(fptr->fd, (struct sockaddr*)&buf, &len) < 0)
 	rb_sys_fail("getsockname(2)");
+    if (len0 < len) len = len0;
     return rb_str_new((char*)&buf, len);
 }
 
@@ -387,11 +389,13 @@ bsock_getpeername(VALUE sock) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/socket/basicsocket.c#L389
 {
     struct sockaddr_storage buf;
     socklen_t len = (socklen_t)sizeof buf;
+    socklen_t len0 = len;
     rb_io_t *fptr;
 
     GetOpenFile(sock, fptr);
     if (getpeername(fptr->fd, (struct sockaddr*)&buf, &len) < 0)
 	rb_sys_fail("getpeername(2)");
+    if (len0 < len) len = len0;
     return rb_str_new((char*)&buf, len);
 }
 
@@ -475,11 +479,13 @@ bsock_local_address(VALUE sock) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/socket/basicsocket.c#L479
 {
     struct sockaddr_storage buf;
     socklen_t len = (socklen_t)sizeof buf;
+    socklen_t len0 = len;
     rb_io_t *fptr;
 
     GetOpenFile(sock, fptr);
     if (getsockname(fptr->fd, (struct sockaddr*)&buf, &len) < 0)
 	rb_sys_fail("getsockname(2)");
+    if (len0 < len) len = len0;
     return rsock_fd_socket_addrinfo(fptr->fd, (struct sockaddr *)&buf, len);
 }
 
@@ -507,11 +513,13 @@ bsock_remote_address(VALUE sock) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/socket/basicsocket.c#L513
 {
     struct sockaddr_storage buf;
     socklen_t len = (socklen_t)sizeof buf;
+    socklen_t len0 = len;
     rb_io_t *fptr;
 
     GetOpenFile(sock, fptr);
     if (getpeername(fptr->fd, (struct sockaddr*)&buf, &len) < 0)
 	rb_sys_fail("getpeername(2)");
+    if (len0 < len) len = len0;
     return rsock_fd_socket_addrinfo(fptr->fd, (struct sockaddr *)&buf, len);
 }
 
Index: ruby_1_9_3/ext/socket/unixsocket.c
===================================================================
--- ruby_1_9_3/ext/socket/unixsocket.c	(revision 39093)
+++ ruby_1_9_3/ext/socket/unixsocket.c	(revision 39094)
@@ -116,8 +116,10 @@ unix_path(VALUE sock) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/socket/unixsocket.c#L116
     if (NIL_P(fptr->pathv)) {
 	struct sockaddr_un addr;
 	socklen_t len = (socklen_t)sizeof(addr);
+	socklen_t len0 = len;
 	if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
 	    rb_sys_fail(0);
+        if (len0 < len) len = len0;
 	fptr->pathv = rb_obj_freeze(rb_str_new_cstr(rsock_unixpath(&addr, len)));
     }
     return rb_str_dup(fptr->pathv);
@@ -445,11 +447,13 @@ unix_peeraddr(VALUE sock) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/socket/unixsocket.c#L447
     rb_io_t *fptr;
     struct sockaddr_un addr;
     socklen_t len = (socklen_t)sizeof addr;
+    socklen_t len0 = len;
 
     GetOpenFile(sock, fptr);
 
     if (getpeername(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
 	rb_sys_fail("getpeername(2)");
+    if (len0 < len) len = len0;
     return rsock_unixaddr(&addr, len);
 }
 
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 39093)
+++ ruby_1_9_3/version.h	(revision 39094)
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 379
+#define RUBY_PATCHLEVEL 380
 
 #define RUBY_RELEASE_DATE "2013-02-06"
 #define RUBY_RELEASE_YEAR 2013

Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r38993


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

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