Blame SOURCES/netkit-ftp-0.17-vsftp165083.patch

04a9bc
--- netkit-ftp-0.17/ftp/ftp.c.vsftp	2005-08-29 16:07:35.000000000 +0200
04a9bc
+++ netkit-ftp-0.17/ftp/ftp.c	2005-08-30 10:58:10.000000000 +0200
04a9bc
@@ -582,6 +582,7 @@
04a9bc
 	volatile long long bytes = 0, hashbytes = HASHBYTES;
04a9bc
 	char buf[BUFSIZ], *bufp;
04a9bc
 	const char *volatile lmode;
04a9bc
+        int old_code_l;
04a9bc
 
04a9bc
 	if (verbose && printnames) {
04a9bc
 		if (local && *local != '-')
04a9bc
@@ -799,7 +800,35 @@
04a9bc
 	(void) fclose(dout);
04a9bc
 	/* closes data as well, so discard it */
04a9bc
 	data = -1;
04a9bc
-	(void) getreply(0);
04a9bc
+	old_code_l = code;
04a9bc
+	(void) getreply(0);
04a9bc
+
04a9bc
+	/* Following "if" will avoid a bug #165083 in ftp-server */
04a9bc
+	/* It can be later removed.                              */
04a9bc
+	if (old_code_l == 150 && code == 150 && cpend == 1
04a9bc
+	    && sunique == 1 && cin !=  NULL && fileno (cin) >=  0 ) {
04a9bc
+		#include <sys/poll.h>
04a9bc
+		struct pollfd  fds_events_l [2] ;
04a9bc
+		int rc;
04a9bc
+
04a9bc
+		fds_events_l [0] .fd = fileno (cin);
04a9bc
+		fds_events_l [0] .events = POLLIN | POLLERR | POLLHUP;
04a9bc
+           
04a9bc
+		rc = poll (fds_events_l, 1, 5000);
04a9bc
+		switch (rc) {
04a9bc
+		case  1:
04a9bc
+			(void) getreply (0);
04a9bc
+			break;
04a9bc
+		case  0:
04a9bc
+			fprintf (stderr, "ftp: no answer from ftp-server "
04a9bc
+			                 "(more than 5 sec).\n");
04a9bc
+			break;
04a9bc
+		case -1:
04a9bc
+			perror("ftp: poll");
04a9bc
+			break;
04a9bc
+		}
04a9bc
+	}
04a9bc
+
04a9bc
 	(void) signal(SIGINT, oldintr);
04a9bc
 	if (oldintp)
04a9bc
 		(void) signal(SIGPIPE, oldintp);