ref: 4b7b1218bf85c1d2894a85bc1b15f9b52d618512
parent: e14eaacce69b9a168deefacafd9b1b768c40cb60
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Jul 12 21:03:17 EDT 2014
ftpd: dont skip unmountnet() and return proper error string from dialdata()
--- a/sys/src/cmd/ip/ftpd.c
+++ b/sys/src/cmd/ip/ftpd.c
@@ -33,7 +33,6 @@
/* maximum ms we'll wait for a command */
Maxwait= 1000*60*30, /* inactive for 30 minutes, we hang up */
- Maxerr= 128,
Maxpath= 512,
};
@@ -161,7 +160,7 @@
{
char buf[8192];
va_list arg;
- char errstr[128];
+ char errstr[ERRMAX];
rerrstr(errstr, sizeof errstr);
va_start(arg, fmt);
@@ -1078,7 +1077,7 @@
dfd = dialdata();
if(dfd < 0){
- reply("425 Error opening data connection:%r");
+ reply("425 Error opening data connection: %r");
return;
}
reply("150 Opened data connection (%s)", data);
@@ -1373,7 +1372,7 @@
reply("150 Opening data connection for %s (%s)", arg, data);
dfd = dialdata();
if(dfd < 0){
- reply("425 Error opening data connection:%r");
+ reply("425 Error opening data connection: %r");
close(fd);
return;
}
@@ -1445,7 +1444,7 @@
reply("150 Opening data connection for %s (%s)", arg, data);
dfd = dialdata();
if(dfd < 0){
- reply("425 Error opening data connection:%r");
+ reply("425 Error opening data connection: %r");
close(fd);
return;
}
@@ -1697,30 +1696,29 @@
{
int fd, cfd;
char ldir[40];
- char err[Maxerr];
+ char err[ERRMAX];
if(mountnet() < 0)
return -1;
- if(!passive.inuse){
+ if(!passive.inuse)
fd = dial(data, "20", 0, 0);
- errstr(err, sizeof err);
- } else {
+ else {
+ fd = -1;
alarm(5*60*1000);
cfd = listen(passive.adir, ldir);
alarm(0);
- errstr(err, sizeof err);
- if(cfd < 0)
- return -1;
- fd = accept(cfd, ldir);
- errstr(err, sizeof err);
- close(cfd);
+ if(cfd >= 0){
+ fd = accept(cfd, ldir);
+ close(cfd);
+ }
}
+ err[0] = 0;
+ errstr(err, sizeof err);
if(fd < 0)
logit("can't dial %s: %s", data, err);
-
unmountnet();
- werrstr(err, sizeof err);
+ errstr(err, sizeof err);
return fd;
}