From 2526fa7d9a981c11ceea62c195eb0e6e15427cb7 Mon Sep 17 00:00:00 2001 From: Jun-ichiro itojun Hagino Date: Fri, 1 Feb 2002 04:53:29 +0000 Subject: make sure pw_dir is big enough for strcpy(pw->pw_dir, "/"). --- libexec/ftpd/ftpd.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'libexec/ftpd/ftpd.c') 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; -- cgit v1.2.3