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

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