mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-02-03 21:52:24 +00:00
Make Windows sockets non-inheritable
When we create a socket with socket() (in try_connect, sk_newlistener, and ipv4_is_local_addr) also call SetHandleInformation to disable handle inheritance for this socket. This fixes dup-sessions-dont-close.
This commit is contained in:
parent
efb4996d31
commit
4455604dbc
@ -774,6 +774,8 @@ static int ipv4_is_local_addr(struct in_addr addr)
|
|||||||
SOCKET s = p_socket(AF_INET, SOCK_DGRAM, 0);
|
SOCKET s = p_socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
DWORD retbytes;
|
DWORD retbytes;
|
||||||
|
|
||||||
|
SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0);
|
||||||
|
|
||||||
if (p_WSAIoctl &&
|
if (p_WSAIoctl &&
|
||||||
p_WSAIoctl(s, SIO_GET_INTERFACE_LIST, NULL, 0,
|
p_WSAIoctl(s, SIO_GET_INTERFACE_LIST, NULL, 0,
|
||||||
local_interfaces, sizeof(local_interfaces),
|
local_interfaces, sizeof(local_interfaces),
|
||||||
@ -1022,6 +1024,8 @@ static DWORD try_connect(Actual_Socket sock)
|
|||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0);
|
||||||
|
|
||||||
if (sock->oobinline) {
|
if (sock->oobinline) {
|
||||||
BOOL b = TRUE;
|
BOOL b = TRUE;
|
||||||
p_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (void *) &b, sizeof(b));
|
p_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (void *) &b, sizeof(b));
|
||||||
@ -1303,6 +1307,8 @@ Socket sk_newlistener(const char *srcaddr, int port, Plug plug,
|
|||||||
return (Socket) ret;
|
return (Socket) ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0);
|
||||||
|
|
||||||
ret->oobinline = 0;
|
ret->oobinline = 0;
|
||||||
|
|
||||||
p_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on));
|
p_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on));
|
||||||
|
Loading…
Reference in New Issue
Block a user