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