Add listening timeout

This commit is contained in:
Jan Synacek 2012-09-25 12:38:53 +02:00
parent 9dae303d10
commit 578bc30861
2 changed files with 27 additions and 0 deletions

View File

@ -37,6 +37,7 @@ Patch28: netkit-ftp-0.17-remove-nested-include.patch
Patch29: netkit-ftp-0.17-linelen.patch
Patch30: netkit-ftp-0.17-active-mode-option.patch
Patch31: netkit-ftp-0.17-commands-leaks.patch
Patch32: netkit-ftp-0.17-lsn-timeout.patch
BuildRequires: glibc-devel, readline-devel, ncurses-devel
@ -81,6 +82,7 @@ file transfers.
%patch29 -p1 -b .linelen
%patch30 -p1 -b .activemode
%patch31 -p1 -b .cmds-leaks
%patch32 -p1 -b .lsn-timeout
%build
sh configure --with-c-compiler=gcc --enable-ipv6
@ -111,6 +113,7 @@ make INSTALLROOT=${RPM_BUILD_ROOT} install
%changelog
* Tue Sep 25 2012 Jan Synáček <jsynacek@redhat.com> - 0.17-60
- Plug leaks in "put", "send", "append"
- Add listening timeout
* Tue Aug 28 2012 Jan Synáček <jsynacek@redhat.com> - 0.17-59
- Add active mode option

View File

@ -0,0 +1,24 @@
--- netkit-ftp-0.17/ftp/ftp.c.to 2012-08-10 15:49:08.510257542 +0200
+++ netkit-ftp-0.17/ftp/ftp.c 2012-08-10 15:49:32.386220785 +0200
@@ -1245,6 +1245,10 @@ initconn(void)
u_int ad[16], po[2], af, alen, plen;
char *pasvcmd = NULL;
char hbuf[MAXHOSTNAMELEN], pbuf[NI_MAXSERV];
+ struct timeval timeout;
+
+ timeout.tv_sec = 30;
+ timeout.tv_usec = 0;
#ifdef INET6
if (myctladdr.su_family == AF_INET6
@@ -1486,6 +1490,10 @@ noport:
perror("ftp: setsockopt (reuse address)");
goto bad;
}
+ if (setsockopt (data, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,
+ sizeof(timeout)) < 0) {
+ perror("ftp: setsockopt failed\n");
+ }
if (bind(data, (struct sockaddr *)&data_addr, sizeof (data_addr)) < 0) {
perror("ftp: bind");
goto bad;