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

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