summaryrefslogtreecommitdiffstats
path: root/libexec/ftpd
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2003-01-16 14:25:32 +0000
committeryar <yar@FreeBSD.org>2003-01-16 14:25:32 +0000
commit65804c6d3c60954609fb5a7c5473a80cc333787a (patch)
tree6f6ecd0d8ea785c41757e65c04ed653c33fe4d85 /libexec/ftpd
parent7417ee0c3e877978bb66f4887b4f7651beffe50d (diff)
downloadFreeBSD-src-65804c6d3c60954609fb5a7c5473a80cc333787a.zip
FreeBSD-src-65804c6d3c60954609fb5a7c5473a80cc333787a.tar.gz
Prepend a space character if a line begins with a digit
in the output to the "STAT file" request. This closes one discrepancy with RFC 959 (page 36.) See also http://www.kb.cert.org/vuls/id/328867 Obtained from: OpenBSD
Diffstat (limited to 'libexec/ftpd')
-rw-r--r--libexec/ftpd/ftpd.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index d64bce4..1f5ce00 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -2092,12 +2092,14 @@ void
statfilecmd(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)){
@@ -2113,7 +2115,16 @@ statfilecmd(char *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");
OpenPOWER on IntegriCloud