diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2002-02-01 04:53:29 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2002-02-01 04:53:29 +0000 |
commit | 2526fa7d9a981c11ceea62c195eb0e6e15427cb7 (patch) | |
tree | e239fb7ae01eccc54b80945f4ad7ee3d98ace1f7 /libexec/ftpd/ftpd.c | |
parent | 99e16f56c85c187bdae2e50387ef0e7f44817af1 (diff) |
make sure pw_dir is big enough for strcpy(pw->pw_dir, "/").
Diffstat (limited to 'libexec/ftpd/ftpd.c')
-rw-r--r-- | libexec/ftpd/ftpd.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index c6c2fa6e4d1..6d5a8c2df2f 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpd.c,v 1.117 2002/01/23 20:59:05 millert Exp $ */ +/* $OpenBSD: ftpd.c,v 1.118 2002/02/01 04:53:28 itojun Exp $ */ /* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */ /* @@ -73,7 +73,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94"; #else -static char rcsid[] = "$OpenBSD: ftpd.c,v 1.117 2002/01/23 20:59:05 millert Exp $"; +static char rcsid[] = "$OpenBSD: ftpd.c,v 1.118 2002/02/01 04:53:28 itojun Exp $"; #endif #endif /* not lint */ @@ -985,6 +985,21 @@ pass(passwd) pw->pw_dir = newdir; } + /* make sure pw->pw_dir is big enough to hold "/" */ + if (strlen(pw->pw_dir) < 1) { + char *newdir; + + newdir = malloc(2); + if (newdir == NULL) { + perror_reply(421, "Local resource failure: malloc"); + dologout(1); + /* NOTREACHED */ + } + strlcpy(newdir, pw->pw_dir, 2); + free(pw->pw_dir); + pw->pw_dir = newdir; + } + if (guest || dochroot) { if (multihome && guest) { struct stat ts; |