cvsdist 7ef7941
--- netkit-ftp-0.17/ftp/ftp.c.segv	2004-06-14 11:04:38.000000000 -0400
cvsdist 7ef7941
+++ netkit-ftp-0.17/ftp/ftp.c	2004-06-14 11:06:46.000000000 -0400
cvsdist 7ef7941
@@ -472,6 +472,8 @@
cvsdist 7ef7941
 					return (0);
cvsdist 7ef7941
 				}
cvsdist 7ef7941
 				lostpeer(0);
cvsdist 7ef7941
+				fclose(cout);
cvsdist 7ef7941
+				cout = NULL;
cvsdist 7ef7941
 				if (verbose) {
cvsdist 7ef7941
 					printf("421 Service not available, remote server has closed connection\n");
cvsdist 7ef7941
 					(void) fflush(stdout);
cvsdist 7ef7941
@@ -529,7 +531,14 @@
cvsdist 7ef7941
 			cpend = 0;
cvsdist 7ef7941
 		(void) signal(SIGINT,oldintr);
cvsdist 7ef7941
 		if (code == 421 || originalcode == 421)
cvsdist 7ef7941
+		{
cvsdist 7ef7941
 			lostpeer(0);
cvsdist 7ef7941
+			if(cout)
cvsdist 7ef7941
+			{
cvsdist 7ef7941
+				fclose(cout);
cvsdist 7ef7941
+				cout = NULL;
cvsdist 7ef7941
+			}
cvsdist 7ef7941
+		}
cvsdist 7ef7941
 		if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN)
cvsdist 7ef7941
 			(*oldintr)(SIGINT);
cvsdist 7ef7941
 		return (n - '0');
cvsdist 7ef7941
@@ -1790,6 +1799,11 @@
cvsdist 7ef7941
 			if (ptabflg)
cvsdist 7ef7941
 				code = -1;
cvsdist 7ef7941
 			lostpeer(0);
cvsdist 7ef7941
+			if(cout != NULL)
cvsdist 7ef7941
+			{
cvsdist 7ef7941
+				fclose(cout);
cvsdist 7ef7941
+				cout = NULL;
cvsdist 7ef7941
+			}
cvsdist 7ef7941
 		}
cvsdist 7ef7941
 		(void) getreply(0);
cvsdist 7ef7941
 		(void) getreply(0);
cvsdist 7ef7941
@@ -1815,6 +1829,11 @@
cvsdist 7ef7941
 			perror("reset");
cvsdist 7ef7941
 			code = -1;
cvsdist 7ef7941
 			lostpeer(0);
cvsdist 7ef7941
+			if(cout != NULL)
cvsdist 7ef7941
+			{
cvsdist 7ef7941
+				fclose(cout);
cvsdist 7ef7941
+				cout = NULL;
cvsdist 7ef7941
+			}
cvsdist 7ef7941
 		}
cvsdist 7ef7941
 		else if (nfnd) {
cvsdist 7ef7941
 			(void) getreply(0);
cvsdist 7ef7941
@@ -1897,6 +1916,11 @@
cvsdist 7ef7941
 		if (ptabflg)
cvsdist 7ef7941
 			code = -1;
cvsdist 7ef7941
 		lostpeer(0);
cvsdist 7ef7941
+		if(cout != NULL)
cvsdist 7ef7941
+		{
cvsdist 7ef7941
+			fclose(cout);
cvsdist 7ef7941
+			cout = NULL;
cvsdist 7ef7941
+		}
cvsdist 7ef7941
 	}
cvsdist 7ef7941
 	if (din && FD_ISSET(fileno(din), &mask)) {
cvsdist 7ef7941
 		while (read(fileno(din), buf, BUFSIZ) > 0)
cvsdist 7ef7941
--- netkit-ftp-0.17/ftp/main.c.segv	2004-06-14 11:03:18.000000000 -0400
cvsdist 7ef7941
+++ netkit-ftp-0.17/ftp/main.c	2004-06-14 11:03:42.000000000 -0400
cvsdist 7ef7941
@@ -235,8 +235,6 @@
cvsdist 7ef7941
 	if (connected) {
cvsdist 7ef7941
 		if (cout != NULL) {
cvsdist 7ef7941
 			shutdown(fileno(cout), 1+1);
cvsdist 7ef7941
-			fclose(cout);
cvsdist 7ef7941
-			cout = NULL;
cvsdist 7ef7941
 		}
cvsdist 7ef7941
 		if (data >= 0) {
cvsdist 7ef7941
 			shutdown(data, 1+1);
cvsdist 7ef7941
@@ -249,8 +247,6 @@
cvsdist 7ef7941
 	if (connected) {
cvsdist 7ef7941
 		if (cout != NULL) {
cvsdist 7ef7941
 			shutdown(fileno(cout), 1+1);
cvsdist 7ef7941
-			fclose(cout);
cvsdist 7ef7941
-			cout = NULL;
cvsdist 7ef7941
 		}
cvsdist 7ef7941
 		connected = 0;
cvsdist 7ef7941
 	}