getpass() can return NULL upon error in some implementations
(as documented in older standards documents, before the API was obsoleted). Problem observed in tnftp on Solaris by Emil Mikulic.
This commit is contained in:
parent
ab47cb33cd
commit
06cab527ea
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: cmds.c,v 1.118 2006/01/31 20:05:35 christos Exp $ */
|
||||
/* $NetBSD: cmds.c,v 1.119 2007/04/11 00:52:38 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1996-2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -103,7 +103,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: cmds.c,v 1.118 2006/01/31 20:05:35 christos Exp $");
|
||||
__RCSID("$NetBSD: cmds.c,v 1.119 2007/04/11 00:52:38 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -1468,6 +1468,7 @@ void
|
||||
user(int argc, char *argv[])
|
||||
{
|
||||
char *password;
|
||||
char emptypass[] = "";
|
||||
int n, aflag = 0;
|
||||
|
||||
if (argc == 0)
|
||||
@ -1485,6 +1486,8 @@ user(int argc, char *argv[])
|
||||
if (n == CONTINUE) {
|
||||
if (argc < 3) {
|
||||
password = getpass("Password: ");
|
||||
if (password == NULL)
|
||||
password = emptypass;
|
||||
} else {
|
||||
password = argv[2];
|
||||
}
|
||||
@ -1495,6 +1498,8 @@ user(int argc, char *argv[])
|
||||
aflag++;
|
||||
if (argc < 4) {
|
||||
password = getpass("Account: ");
|
||||
if (password == NULL)
|
||||
password = emptypass;
|
||||
} else {
|
||||
password = argv[3];
|
||||
}
|
||||
@ -1782,6 +1787,7 @@ void
|
||||
account(int argc, char *argv[])
|
||||
{
|
||||
char *ap;
|
||||
char emptypass[] = "";
|
||||
|
||||
if (argc == 0 || argc > 2) {
|
||||
UPRINTF("usage: %s [password]\n", argv[0]);
|
||||
@ -1790,9 +1796,13 @@ account(int argc, char *argv[])
|
||||
}
|
||||
else if (argc == 2)
|
||||
ap = argv[1];
|
||||
else
|
||||
else {
|
||||
ap = getpass("Account:");
|
||||
if (ap == NULL)
|
||||
ap = emptypass;
|
||||
}
|
||||
(void)command("ACCT %s", ap);
|
||||
memset(ap, 0, strlen(ap));
|
||||
}
|
||||
|
||||
sigjmp_buf abortprox;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: fetch.c,v 1.173 2006/12/13 18:04:08 christos Exp $ */
|
||||
/* $NetBSD: fetch.c,v 1.174 2007/04/11 00:52:38 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2006 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1997-2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: fetch.c,v 1.173 2006/12/13 18:04:08 christos Exp $");
|
||||
__RCSID("$NetBSD: fetch.c,v 1.174 2007/04/11 00:52:38 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -199,8 +199,13 @@ auth_url(const char *challenge, char **response, const char *guser,
|
||||
}
|
||||
if (gpass != NULL)
|
||||
pass = (char *)gpass;
|
||||
else
|
||||
else {
|
||||
pass = getpass("Password: ");
|
||||
if (pass == NULL) {
|
||||
warnx("Can't read password");
|
||||
goto cleanup_auth_url;
|
||||
}
|
||||
}
|
||||
|
||||
clen = strlen(user) + strlen(pass) + 2; /* user + ":" + pass + "\0" */
|
||||
clear = (char *)ftp_malloc(clen);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: util.c,v 1.135 2006/05/23 23:59:48 jnemeth Exp $ */
|
||||
/* $NetBSD: util.c,v 1.136 2007/04/11 00:52:38 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2005 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1997-2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -71,7 +71,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: util.c,v 1.135 2006/05/23 23:59:48 jnemeth Exp $");
|
||||
__RCSID("$NetBSD: util.c,v 1.136 2007/04/11 00:52:38 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -379,6 +379,7 @@ ftp_login(const char *host, const char *luser, const char *lpass)
|
||||
{
|
||||
char tmp[80];
|
||||
char *user, *pass, *acct, *p;
|
||||
char emptypass[] = "";
|
||||
const char *errormsg;
|
||||
int n, aflag, rval, nlen;
|
||||
|
||||
@ -443,6 +444,8 @@ ftp_login(const char *host, const char *luser, const char *lpass)
|
||||
if (n == CONTINUE) {
|
||||
if (pass == NULL) {
|
||||
p = getpass("Password: ");
|
||||
if (p == NULL)
|
||||
p = emptypass;
|
||||
pass = ftp_strdup(p);
|
||||
memset(p, 0, strlen(p));
|
||||
}
|
||||
@ -453,6 +456,8 @@ ftp_login(const char *host, const char *luser, const char *lpass)
|
||||
aflag++;
|
||||
if (acct == NULL) {
|
||||
p = getpass("Account: ");
|
||||
if (p == NULL)
|
||||
p = emptypass;
|
||||
acct = ftp_strdup(p);
|
||||
memset(p, 0, strlen(p));
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* $NetBSD: version.h,v 1.58 2006/07/26 14:28:11 lukem Exp $ */
|
||||
/* $NetBSD: version.h,v 1.59 2007/04/11 00:52:38 lukem Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1999-2006 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1999-2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -40,5 +40,5 @@
|
||||
#endif
|
||||
|
||||
#ifndef FTP_VERSION
|
||||
#define FTP_VERSION "20060726"
|
||||
#define FTP_VERSION "20070410"
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user