summaryrefslogtreecommitdiff
path: root/libexec/ftpd/ftpd.c
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-12-04 10:49:32 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-12-04 10:49:32 +0000
commitd9ef0c4b60276be336b4158ae28366b9d44f0ce6 (patch)
tree9a0630a225a298730088456900aae3dc389c37f8 /libexec/ftpd/ftpd.c
parent6b490148d9d35bfad129b10fa00836d22e8f1e52 (diff)
in replydirname(), avoid one-byte overrun.
From: Kristian Vlaardingerbroek <kris@obit.nl>
Diffstat (limited to 'libexec/ftpd/ftpd.c')
-rw-r--r--libexec/ftpd/ftpd.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 5e36a269c3f..5ccc5aec090 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpd.c,v 1.83 2000/12/02 18:01:11 millert Exp $ */
+/* $OpenBSD: ftpd.c,v 1.84 2000/12/04 10:49:31 itojun Exp $ */
/* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */
/*
@@ -1964,15 +1964,21 @@ void
replydirname(name, message)
const char *name, *message;
{
+ char *p, *ep;
char npath[MAXPATHLEN];
- int i;
- for (i = 0; *name != '\0' && i < sizeof(npath) - 1; i++, name++) {
- npath[i] = *name;
- if (*name == '"')
- npath[++i] = '"';
+ p = npath;
+ ep = &npath[sizeof(npath) - 1];
+ while (*name) {
+ if (*name == '"' && ep - p >= 2) {
+ *p++ = *name++;
+ *p++ = '"';
+ } else if (ep - p >= 1)
+ *p++ = *name++;
+ else
+ break;
}
- npath[i] = '\0';
+ *p = '\0';
reply(257, "\"%s\" %s", npath, message);
}