1
0
mirror of https://github.com/InfrastructureServices/vsftpd.git synced 2025-04-19 01:24:02 +03:00

Move closing standard FDs after listen()

The vsf_sysutil_close() calls need to be moved a bit further so that
die() works properly in case listen() fails.

I see no reason the calls should be placed before listen()
specifically, as they are now. My guess is that the author who added
the calls thought that listen() is a blocking call, which is not the
case. The only thing we need to satisfy is that close() is called
before accept, because that is a blocking call. That's all that is
needed to fix the bug that was fixed by adding the close() calls.

Resolves: rhbz#1666380
This commit is contained in:
Ondřej Lysoněk 2019-08-03 17:50:14 +02:00
parent 970711fde9
commit 40fea45523

View File

@ -152,15 +152,15 @@ vsf_standalone_main(void)
vsf_sysutil_kill(vsf_sysutil_getppid(), kVSFSysUtilSigUSR1);
}
}
vsf_sysutil_close(0);
vsf_sysutil_close(1);
vsf_sysutil_close(2);
retval = vsf_sysutil_listen(listen_sock, VSFTP_LISTEN_BACKLOG);
if (vsf_sysutil_retval_is_error(retval))
{
die("could not listen");
}
vsf_sysutil_sockaddr_alloc(&p_accept_addr);
vsf_sysutil_close(0);
vsf_sysutil_close(1);
vsf_sysutil_close(2);
while (1)
{
struct vsf_client_launch child_info;