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

ruby-changes:32411

From: charliesome <ko1@a...>
Date: Fri, 3 Jan 2014 19:12:45 +0900 (JST)
Subject: [ruby-changes:32411] charliesome:r44490 (trunk): * ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno

charliesome	2014-01-03 19:12:38 +0900 (Fri, 03 Jan 2014)

  New Revision: 44490

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

  Log:
    * ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno
      before calling rb_sys_fail_str to prevent [BUG] errno == 0.
      Patch by Eric Wong. [ruby-core:59498] [Bug #9352]
    
    * ext/socket/socket.c (rsock_sys_fail_path): ditto
    * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto
    * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto
    * ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/socket.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44489)
+++ ChangeLog	(revision 44490)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jan  3 19:09:00 2014  Eric Wong  <normalperson@y...>
+
+	* ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno
+	  before calling rb_sys_fail_str to prevent [BUG] errno == 0.
+	  Patch by Eric Wong. [ruby-core:59498] [Bug #9352]
+
+	* ext/socket/socket.c (rsock_sys_fail_path): ditto
+	* ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto
+	* ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto
+	* ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto
+
 Fri Jan  3 10:43:57 2014  Aman Gupta <ruby@t...>
 
 	* test/net/imap/cacert.pem: generate new CA cert, since the last one
Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c	(revision 44489)
+++ ext/socket/socket.c	(revision 44490)
@@ -16,12 +16,14 @@ void https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L16
 rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port)
 {
     VALUE message;
+    int err = errno;
 
     port = rb_String(port);
 
     message = rb_sprintf("%s for \"%s\" port %s",
 	    mesg, StringValueCStr(host), StringValueCStr(port));
 
+    errno = err;
     rb_sys_fail_str(message);
 }
 
@@ -29,6 +31,8 @@ void https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L31
 rsock_sys_fail_path(const char *mesg, VALUE path)
 {
     VALUE message;
+    int err = errno;
+
     if (RB_TYPE_P(path, T_STRING)) {
         if (memchr(RSTRING_PTR(path), '\0', RSTRING_LEN(path))) {
             path = rb_str_inspect(path);
@@ -39,6 +43,7 @@ rsock_sys_fail_path(const char *mesg, VA https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L43
             message = rb_sprintf("%s for \"%s\"", mesg,
                     StringValueCStr(path));
         }
+        errno = err;
         rb_sys_fail_str(message);
     }
     else {
@@ -50,9 +55,11 @@ void https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L55
 rsock_sys_fail_sockaddr(const char *mesg, struct sockaddr *addr, socklen_t len)
 {
     VALUE rai;
+    int err = errno;
 
     rai = rsock_addrinfo_new(addr, len, PF_UNSPEC, 0, 0, Qnil, Qnil);
 
+    errno = err;
     rsock_sys_fail_raddrinfo(mesg, rai);
 }
 
@@ -60,18 +67,24 @@ void https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L67
 rsock_sys_fail_raddrinfo(const char *mesg, VALUE rai)
 {
     VALUE str, message;
+    int err = errno;
 
     str = rsock_addrinfo_inspect_sockaddr(rai);
     message = rb_sprintf("%s for %s", mesg, StringValueCStr(str));
 
+    errno = err;
     rb_sys_fail_str(message);
 }
 
 void
 rsock_sys_fail_raddrinfo_or_sockaddr(const char *mesg, VALUE addr, VALUE rai)
 {
+    int err = errno;
+
     if (NIL_P(rai)) {
         StringValue(addr);
+
+        errno = err;
         rsock_sys_fail_sockaddr(mesg,
             (struct sockaddr *)RSTRING_PTR(addr),
             (socklen_t)RSTRING_LEN(addr)); /* overflow should be checked already */

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

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