Subject: Re: bin/9642: ftpd(8) may forget data connection in passive mode.
To: None <gnats-bugs@gnats.netbsd.org>
From: Takahiro Kambe <taca@sky.yamashina.kyoto.jp>
List: netbsd-bugs
Date: 03/19/2000 11:31:55
This problem also exists when none retreiving non-existing file,
pointed by TANAKA Hirosachi <c1995207@uhura.nit.ac.jp>.
This is revised fix.
Index: ftpd.c
===================================================================
RCS file: /usr/local/libdata/cvs/netbsd/libexec/ftpd/ftpd.c,v
retrieving revision 1.1.1.16
diff -u -r1.1.1.16 ftpd.c
--- ftpd.c 2000/03/05 16:17:02 1.1.1.16
+++ ftpd.c 2000/03/19 02:28:03
@@ -1087,7 +1087,6 @@
timersub(&finish, &start, &td);
tdp = &td;
data = -1;
- pdata = -1;
done:
if (log)
logcmd("get", byte_count, name, NULL, tdp, NULL);
@@ -1124,6 +1123,10 @@
reply(226, "Transfer complete.");
}
cleanupretrieve:
+ if (pdata >= 0) {
+ (void) close(pdata);
+ }
+ pdata = -1;
if (stderrfd != -1)
(void)close(stderrfd);
if (isconversion)
@@ -1202,8 +1205,11 @@
timersub(&finish, &start, &td);
tdp = &td;
data = -1;
- pdata = -1;
done:
+ if (pdata >= 0) {
+ (void) close(pdata);
+ }
+ pdata = -1;
logcmd(desc, byte_count, name, NULL, tdp, NULL);
(*closefunc)(fout);
}
@@ -2588,6 +2594,10 @@
transflag = 0;
if (dout != NULL)
(void) fclose(dout);
+ else {
+ if (pdata >= 0)
+ (void) close(pdata);
+ }
data = -1;
pdata = -1;
out:
--
Takahiro Kambe <taca@sky.yamashina.kyoto.jp>