From b73df28420047b5b68c919176bc03f63d104378d Mon Sep 17 00:00:00 2001 From: ray Date: Fri, 30 Jul 2010 11:02:56 +0000 Subject: [PATCH] Don't set "success" flags before error checks. Add check for login_getclass() failure, pointed out by tobias. OK tobias --- libexec/ftpd/ftpd.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 1f65a156ced..500cb93f20d 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpd.c,v 1.189 2010/06/18 06:02:57 tobias Exp $ */ +/* $OpenBSD: ftpd.c,v 1.190 2010/07/30 11:02:56 ray Exp $ */ /* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */ /* @@ -740,21 +740,23 @@ user(char *name) checkuser(_PATH_FTPUSERS, "anonymous")) reply(530, "User %s access denied.", name); else if ((pw = sgetpwnam("ftp", NULL)) != NULL) { - guest = 1; - askpasswd = 1; - lc = login_getclass(pw->pw_class); - if ((as = auth_open()) == NULL || + if ((lc = login_getclass(pw->pw_class)) == NULL || + (as = auth_open()) == NULL || auth_setpwd(as, pw) != 0 || auth_setoption(as, "FTPD_HOST", host) < 0) { if (as) { auth_close(as); as = NULL; } - login_close(lc); - lc = NULL; + if (lc) { + login_close(lc); + lc = NULL; + } reply(421, "Local resource failure"); return; } + guest = 1; + askpasswd = 1; reply(331, "Guest login ok, send your email address as password."); } else -- 2.20.1