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

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