Skip to content
Snippets Groups Projects
Commit e53f1731 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Remove unnecessary call to DuplicateHandle() in Win32 builds of sbbs_t::init()

The client_socket_dup is overwritten after with the return value of accept(),
so this was likely a socket/handle leak (since commit 74470573, 17 years ago).

Noticed this only after logging a new error in an SSH connection when this
call to DuplicateHandle() failed for some reason (WinError 6), but it seems
like it's been redundant code for a long time now. So just ace it and possibly
fix a resource leak.
parent 518ecda9
No related branches found
No related tags found
No related merge requests found
Pipeline #5354 passed
...@@ -3466,22 +3466,6 @@ bool sbbs_t::init() ...@@ -3466,22 +3466,6 @@ bool sbbs_t::init()
if(cfg.node_num && client_socket!=INVALID_SOCKET) { if(cfg.node_num && client_socket!=INVALID_SOCKET) {
#ifdef _WIN32
if(!DuplicateHandle(GetCurrentProcess(),
(HANDLE)client_socket,
GetCurrentProcess(),
(HANDLE*)&client_socket_dup,
0,
true, // Inheritable
DUPLICATE_SAME_ACCESS)) {
errormsg(WHERE,ERR_CREATE,"duplicate socket handle",client_socket);
return(false);
}
lprintf(LOG_DEBUG,"socket %u duplicated as %u", client_socket, client_socket_dup);
#else
client_socket_dup = client_socket;
#endif
addr_len=sizeof(addr); addr_len=sizeof(addr);
if((result=getsockname(client_socket, &addr.addr, &addr_len))!=0) { if((result=getsockname(client_socket, &addr.addr, &addr_len))!=0) {
lprintf(LOG_CRIT,"!ERROR %d (%d) getting local address/port of socket" lprintf(LOG_CRIT,"!ERROR %d (%d) getting local address/port of socket"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment