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

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