09d58c
--- netkit-ftp-0.17/ftp/ftp.c.data	2005-12-02 15:31:27.000000000 +0100
09d58c
+++ netkit-ftp-0.17/ftp/ftp.c	2005-12-02 15:35:46.000000000 +0100
09d58c
@@ -1223,6 +1223,7 @@
09d58c
 static int
09d58c
 initconn(void)
09d58c
 {
09d58c
+	int rc;
09d58c
 	u_char *p, *a;
09d58c
 	int result, tmpno = 0;
09d58c
 	socklen_t len;
09d58c
@@ -1240,6 +1241,13 @@
09d58c
 	}
09d58c
 #endif
09d58c
 	if (passivemode) {
09d58c
+		if (data >= 0){
09d58c
+			rc = close (data);
09d58c
+			data = -1;
09d58c
+			if (rc == -1){
09d58c
+				perror ("ftp: close");
09d58c
+			}
09d58c
+		}
09d58c
 		data_addr = hisctladdr;
09d58c
 		data = socket(data_addr.su_family, SOCK_STREAM, 0);
09d58c
 		if (data < 0) {