summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2010-07-30 11:02:57 +0000
committerRay Lai <ray@cvs.openbsd.org>2010-07-30 11:02:57 +0000
commit10842f0370d5a7c124ac7bd480b0326fe40115b3 (patch)
treea4ed2e9cd74d367a5fbb22d70e6134a7266817e0
parent3d39b152d50affc4607d902b9f11332512b72e32 (diff)
Don't set "success" flags before error checks.
Add check for login_getclass() failure, pointed out by tobias. OK tobias
-rw-r--r--libexec/ftpd/ftpd.c16
1 files 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