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

ruby-changes:33392

From: usa <ko1@a...>
Date: Sun, 30 Mar 2014 23:42:59 +0900 (JST)
Subject: [ruby-changes:33392] usa:r45471 (trunk): * win32/win32.c (rb_w32_accept, open_ifs_socket, socketpair_internal):

usa	2014-03-30 23:42:52 +0900 (Sun, 30 Mar 2014)

  New Revision: 45471

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

  Log:
    * win32/win32.c (rb_w32_accept, open_ifs_socket, socketpair_internal):
      reset inherit flag of socket to avoid unintentional inheritance of
      socket.  note that the return value of SetHandleInformation() is not
      verified intentionally because old Windows may return an error.
      [Bug #9688] [ruby-core:61754]

  Modified files:
    trunk/ChangeLog
    trunk/win32/win32.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45470)
+++ ChangeLog	(revision 45471)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Mar 30 23:39:26 2014  NAKAMURA Usaku  <usa@r...>
+
+	* win32/win32.c (rb_w32_accept, open_ifs_socket, socketpair_internal):
+	  reset inherit flag of socket to avoid unintentional inheritance of
+	  socket.  note that the return value of SetHandleInformation() is not
+	  verified intentionally because old Windows may return an error.
+	  [Bug #9688] [ruby-core:61754]
+
 Sat Mar 29 13:04:22 2014  Koichi Sasada  <ko1@a...>
 
 	* gc.c (gc_before_sweep): cap `malloc_limit' to
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 45470)
+++ win32/win32.c	(revision 45471)
@@ -3017,6 +3017,7 @@ rb_w32_accept(int s, struct sockaddr *ad https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L3017
 	if (fd != -1) {
 	    r = accept(TO_SOCKET(s), addr, addrlen);
 	    if (r != INVALID_SOCKET) {
+		SetHandleInformation((HANDLE)r, HANDLE_FLAG_INHERIT, 0);
 		MTHREAD_ONLY(EnterCriticalSection(&(_pioinfo(fd)->lock)));
 		_set_osfhnd(fd, r);
 		MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
@@ -3557,6 +3558,8 @@ open_ifs_socket(int af, int type, int pr https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L3558
 		}
 		if (out == INVALID_SOCKET)
 		    out = WSASocket(af, type, protocol, NULL, 0, 0);
+		if (out != INVALID_SOCKET)
+		    SetHandleInformation((HANDLE)out, HANDLE_FLAG_INHERIT, 0);
 	    }
 
 	    free(proto_buffers);
@@ -3790,6 +3793,7 @@ socketpair_internal(int af, int type, in https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L3793
 	    r = accept(svr, addr, &len);
 	    if (r == INVALID_SOCKET)
 		break;
+	    SetHandleInformation((HANDLE)r, HANDLE_FLAG_INHERIT, 0);
 
 	    ret = 0;
 	} while (0);

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

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