summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-01 17:21:10 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-01 17:21:10 +0000
commite373773ab3b798fc80ab0424e27f8e870d25908f (patch)
treed0bd8f0278ebde52cf5de27e9c430edb0783dbf1 /win32
parent282462b206b0d6643f272e1e4a4b45f148688b18 (diff)
merge revision(s) r45471: [Backport #9688]
* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 2c888ae4c4..9fd981ec56 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -3017,6 +3017,7 @@ rb_w32_accept(int s, struct sockaddr *addr, int *addrlen)
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 protocol)
}
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, int protocol, SOCKET *sv)
r = accept(svr, addr, &len);
if (r == INVALID_SOCKET)
break;
+ SetHandleInformation((HANDLE)r, HANDLE_FLAG_INHERIT, 0);
ret = 0;
} while (0);