Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/ftp * fix ftp_login() so that -a always logs in anon...
details: https://anonhg.NetBSD.org/src/rev/28df32d09e12
branches: trunk
changeset: 472721:28df32d09e12
user: lukem <lukem%NetBSD.org@localhost>
date: Wed May 05 16:04:58 1999 +0000
description:
* fix ftp_login() so that -a always logs in anonymously, even if a
.netrc entry exists for the host with a valid user. noted by
Frederick Bruckman <fb%enteract.com@localhost> in [bin/7477]
* fix a minor memory leak associated with calling ruserpass() with
an empty user, password, or account.
diffstat:
usr.bin/ftp/util.c | 47 ++++++++++++++++++++++++++++++++---------------
1 files changed, 32 insertions(+), 15 deletions(-)
diffs (102 lines):
diff -r 69d29732cb08 -r 28df32d09e12 usr.bin/ftp/util.c
--- a/usr.bin/ftp/util.c Wed May 05 15:32:33 1999 +0000
+++ b/usr.bin/ftp/util.c Wed May 05 16:04:58 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: util.c,v 1.46 1999/03/08 03:09:08 lukem Exp $ */
+/* $NetBSD: util.c,v 1.47 1999/05/05 16:04:58 lukem Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: util.c,v 1.46 1999/03/08 03:09:08 lukem Exp $");
+__RCSID("$NetBSD: util.c,v 1.47 1999/05/05 16:04:58 lukem Exp $");
#endif /* not lint */
/*
@@ -251,20 +251,15 @@
const char *acct;
char anonpass[MAXLOGNAME + 2]; /* "user@" */
struct passwd *pw;
- int n, aflag = 0;
+ int n, aflag, rval, freeuser, freepass, freeacct;
acct = NULL;
- if (user == NULL) {
- if (ruserpass(host, &user, &pass, &acct) < 0) {
- code = -1;
- return (0);
- }
- }
+ aflag = rval = freeuser = freepass = freeacct = 0;
/*
* Set up arguments for an anonymous FTP session, if necessary.
*/
- if ((user == NULL || pass == NULL) && anonftp) {
+ if (anonftp) {
memset(anonpass, 0, sizeof(anonpass));
/*
@@ -291,6 +286,17 @@
user = "anonymous"; /* as per RFC 1635 */
}
+ if (user == NULL) {
+ freeuser = 1;
+ if (pass == NULL)
+ freepass = 1;
+ freeacct = 1;
+ if (ruserpass(host, &user, &pass, &acct) < 0) {
+ code = -1;
+ goto cleanup_ftp_login;
+ }
+ }
+
while (user == NULL) {
const char *myname = getlogin();
@@ -316,17 +322,21 @@
}
if (n == CONTINUE) {
aflag++;
- if (acct == NULL)
+ if (acct == NULL) {
acct = getpass("Account:");
+ freeacct = 0;
+ }
n = command("ACCT %s", acct);
}
if ((n != COMPLETE) ||
(!aflag && acct != NULL && command("ACCT %s", acct) != COMPLETE)) {
warnx("Login failed.");
- return (0);
+ goto cleanup_ftp_login;
}
- if (proxy)
- return (1);
+ if (proxy) {
+ rval = 1;
+ goto cleanup_ftp_login;
+ }
connected = -1;
for (n = 0; n < macnum; ++n) {
if (!strcmp("init", macros[n].mac_name)) {
@@ -336,7 +346,14 @@
break;
}
}
- return (1);
+cleanup_ftp_login:
+ if (user != NULL && freeuser)
+ free((char *)user);
+ if (pass != NULL && freepass)
+ free((char *)pass);
+ if (acct != NULL && freeacct)
+ free((char *)acct);
+ return (rval);
}
/*
Home |
Main Index |
Thread Index |
Old Index