summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorYaroslav Tykhiy <ytykhiy@gmail.com>2003-01-30 13:01:49 +0000
committerYaroslav Tykhiy <ytykhiy@gmail.com>2003-01-30 13:01:49 +0000
commit1a7d47149998693aebfc47822704707c9b7929ae (patch)
tree6582dfe08cabdda9ff77f87e71b20e5a779c6e0c /libexec
parentd2d8451112469cf7094800c506a2548022f5a28a (diff)
Notes
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ftpd/ftpcmd.y21
-rw-r--r--libexec/ftpd/ftpd.c11
2 files changed, 28 insertions, 4 deletions
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y
index b1ec2079dd99..9f7bbd4aa9f9 100644
--- a/libexec/ftpd/ftpcmd.y
+++ b/libexec/ftpd/ftpcmd.y
@@ -972,8 +972,10 @@ pathname
*/
if (logged_in && $1) {
glob_t gl;
+ char *p, **pp;
int flags =
GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE;
+ int n;
memset(&gl, 0, sizeof(gl));
flags |= GLOB_LIMIT;
@@ -982,11 +984,22 @@ pathname
gl.gl_pathc == 0) {
reply(550, "wildcard expansion error");
$$ = NULL;
- } else if (gl.gl_pathc > 1) {
- reply(550, "ambiguous");
- $$ = NULL;
} else {
- $$ = strdup(gl.gl_pathv[0]);
+ n = 0;
+ for (pp = gl.gl_pathv; *pp; pp++)
+ if (strcspn(*pp, "\r\n") ==
+ strlen(*pp)) {
+ p = *pp;
+ n++;
+ }
+ if (n == 0)
+ $$ = strdup($1);
+ else if (n == 1)
+ $$ = strdup(p);
+ else {
+ reply(550, "ambiguous");
+ $$ = NULL;
+ }
}
globfree(&gl);
free($1);
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index dd7a17a229ca..47d596ed3605 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -2079,12 +2079,14 @@ statfilecmd(filename)
char *filename;
{
FILE *fin;
+ int atstart;
int c;
char line[LINE_MAX];
(void)snprintf(line, sizeof(line), _PATH_LS " -lgA %s", filename);
fin = ftpd_popen(line, "r");
lreply(211, "status of %s:", filename);
+ atstart = 1;
while ((c = getc(fin)) != EOF) {
if (c == '\n') {
if (ferror(stdout)){
@@ -2100,7 +2102,16 @@ statfilecmd(filename)
}
(void) putc('\r', stdout);
}
+ /*
+ * RFC 959 says neutral text should be prepended before
+ * a leading 3-digit number followed by whitespace, but
+ * many ftp clients can be confused by any leading digits,
+ * as a matter of fact.
+ */
+ if (atstart && isdigit(c))
+ (void) putc(' ', stdout);
(void) putc(c, stdout);
+ atstart = (c == '\n');
}
(void) ftpd_pclose(fin);
reply(211, "End of Status");