Mercurial > dropbear
changeset 270:50da8d4b5acd
merge of c9dc9c734d4724866a86987356e6aedeed1c93dd
and fe38e5c38c2e7d5a4bb76aee511d345f1c2d5ac2
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 25 Jan 2006 17:14:32 +0000 |
parents | 475a818dd6e7 (diff) 92b9b182c615 (current diff) |
children | be18c7dd486e |
files | |
diffstat | 5 files changed, 19 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/auth.h Wed Jan 25 17:13:38 2006 +0000 +++ b/auth.h Wed Jan 25 17:14:32 2006 +0000 @@ -52,6 +52,7 @@ void cli_auth_password(); int cli_auth_pubkey(); void cli_auth_interactive(); +char* getpass_or_cancel(); #define MAX_USERNAME_LEN 25 /* arbitrary for the moment */
--- a/cli-auth.c Wed Jan 25 17:13:38 2006 +0000 +++ b/cli-auth.c Wed Jan 25 17:14:32 2006 +0000 @@ -278,3 +278,18 @@ TRACE(("leave cli_auth_try")) } + +/* A helper for getpass() that exits if the user cancels. The returned + * password is statically allocated by getpass() */ +char* getpass_or_cancel() +{ + char* password = NULL; + + password = getpass("Password: "); + + /* 0x03 is a ctrl-c character in the buffer. */ + if (password == NULL || strchr(password, '\3') != NULL) { + dropbear_close("Interrupted."); + } + return password; +}
--- a/cli-authinteract.c Wed Jan 25 17:13:38 2006 +0000 +++ b/cli-authinteract.c Wed Jan 25 17:14:32 2006 +0000 @@ -115,7 +115,7 @@ echo = buf_getbool(ses.payload); if (!echo) { - unsigned char* p = getpass(prompt); + unsigned char* p = getpass_or_cancel(prompt); response = m_strdup(p); m_burn(p, strlen(p)); } else {
--- a/cli-authpasswd.c Wed Jan 25 17:13:38 2006 +0000 +++ b/cli-authpasswd.c Wed Jan 25 17:14:32 2006 +0000 @@ -125,10 +125,7 @@ password = gui_getpass("Password: "); else #endif - password = getpass("Password: "); - - if (password == NULL) - return 0; + password = getpass_or_cancel("Password: "); buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_REQUEST);
--- a/svr-tcpfwd.c Wed Jan 25 17:13:38 2006 +0000 +++ b/svr-tcpfwd.c Wed Jan 25 17:14:32 2006 +0000 @@ -80,7 +80,7 @@ reqname = buf_getstring(ses.payload, &namelen); wantreply = buf_getbool(ses.payload); - if (namelen > MAXNAMLEN) { + if (namelen > MAX_NAME_LEN) { TRACE(("name len is wrong: %d", namelen)) goto out; }