summaryrefslogtreecommitdiff
path: root/source/n/netkit-ftp/patches/04-netkit-ftp-0.17-segv.patch
blob: 12d59608d57090e63a4a6689d54f2db1dfecb266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--- netkit-ftp-0.17/ftp/ftp.c.segv	2004-06-14 11:04:38.000000000 -0400
+++ netkit-ftp-0.17/ftp/ftp.c	2004-06-14 11:06:46.000000000 -0400
@@ -472,6 +472,8 @@
 					return (0);
 				}
 				lostpeer(0);
+				fclose(cout);
+				cout = NULL;
 				if (verbose) {
 					printf("421 Service not available, remote server has closed connection\n");
 					(void) fflush(stdout);
@@ -529,7 +531,14 @@
 			cpend = 0;
 		(void) signal(SIGINT,oldintr);
 		if (code == 421 || originalcode == 421)
+		{
 			lostpeer(0);
+			if(cout)
+			{
+				fclose(cout);
+				cout = NULL;
+			}
+		}
 		if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN)
 			(*oldintr)(SIGINT);
 		return (n - '0');
@@ -1790,6 +1799,11 @@
 			if (ptabflg)
 				code = -1;
 			lostpeer(0);
+			if(cout != NULL)
+			{
+				fclose(cout);
+				cout = NULL;
+			}
 		}
 		(void) getreply(0);
 		(void) getreply(0);
@@ -1815,6 +1829,11 @@
 			perror("reset");
 			code = -1;
 			lostpeer(0);
+			if(cout != NULL)
+			{
+				fclose(cout);
+				cout = NULL;
+			}
 		}
 		else if (nfnd) {
 			(void) getreply(0);
@@ -1897,6 +1916,11 @@
 		if (ptabflg)
 			code = -1;
 		lostpeer(0);
+		if(cout != NULL)
+		{
+			fclose(cout);
+			cout = NULL;
+		}
 	}
 	if (din && FD_ISSET(fileno(din), &mask)) {
 		while (read(fileno(din), buf, BUFSIZ) > 0)
--- netkit-ftp-0.17/ftp/main.c.segv	2004-06-14 11:03:18.000000000 -0400
+++ netkit-ftp-0.17/ftp/main.c	2004-06-14 11:03:42.000000000 -0400
@@ -235,8 +235,6 @@
 	if (connected) {
 		if (cout != NULL) {
 			shutdown(fileno(cout), 1+1);
-			fclose(cout);
-			cout = NULL;
 		}
 		if (data >= 0) {
 			shutdown(data, 1+1);
@@ -249,8 +247,6 @@
 	if (connected) {
 		if (cout != NULL) {
 			shutdown(fileno(cout), 1+1);
-			fclose(cout);
-			cout = NULL;
 		}
 		connected = 0;
 	}