From: Tom Yu Date: Fri, 11 Oct 2002 06:05:09 +0000 (+0000) Subject: implement krb5_read_password, des_read_password via krb5_prompter_posix X-Git-Tag: krb5-1.3-alpha1~329 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e5bb9ff79118abbd1e2a30fb170c3fbeaa032ccd;p=krb5.git implement krb5_read_password, des_read_password via krb5_prompter_posix This commit fixes one incompatibility introduced when krb5_read_password was reimplemented in terms of krb5_prompter_posix. There is a remaining incompatibility, which is krb5_prompter_posix's appending of the string ": " following a prompt. Callers of krb5_read_password and of des_read_password don't expect this behavior, which results in a double colon prompt, which breaks the libkadm5 test suite. * read_pwd.c (krb5_read_password): Restore name of size_return. Set *size_return after successful call to krb5_prompter_posix, since some callers were actually checking, e.g. kadm5. ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14922 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index 5f5bf002c..7e80873fe 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,9 @@ +2002-10-11 Tom Yu + + * read_pwd.c (krb5_read_password): Restore name of size_return. + Set *size_return after successful call to krb5_prompter_posix, + since some callers were actually checking, e.g. kadm5. + 2002-10-10 Sam Hartman * read_pwd.c (krb5_read_password): Reimplement in terms of krb5_prompter_posix for unix diff --git a/src/lib/krb5/os/read_pwd.c b/src/lib/krb5/os/read_pwd.c index e113df469..73a3670f1 100644 --- a/src/lib/krb5/os/read_pwd.c +++ b/src/lib/krb5/os/read_pwd.c @@ -41,12 +41,12 @@ #endif /* ECHO_PASSWORD */ krb5_error_code -krb5_read_password(krb5_context context, const char *prompt, const char *prompt2, char *return_pwd, unsigned int *bufsize_in) +krb5_read_password(krb5_context context, const char *prompt, const char *prompt2, char *return_pwd, unsigned int *size_return) { krb5_data reply_data; krb5_prompt k5prompt; krb5_error_code retval; - reply_data.length = *bufsize_in; + reply_data.length = *size_return; /* NB: size_return is also an input */ reply_data.data = return_pwd; k5prompt.prompt = (const char *) prompt; k5prompt.hidden = 1; @@ -56,8 +56,8 @@ krb5_read_password(krb5_context context, const char *prompt, const char *prompt2 if ((retval==0) && prompt2) { krb5_data verify_data; - verify_data.data = malloc(*bufsize_in); - verify_data.length = *bufsize_in; + verify_data.data = malloc(*size_return); + verify_data.length = *size_return; k5prompt.prompt = (const char *) prompt2; k5prompt.reply = &verify_data; if (!verify_data.data) @@ -68,12 +68,16 @@ krb5_read_password(krb5_context context, const char *prompt, const char *prompt2 free(verify_data.data); } else { /* compare */ - if (strncmp(return_pwd, (char *)verify_data.data, *bufsize_in)) { + if (strncmp(return_pwd, (char *)verify_data.data, *size_return)) { retval = KRB5_LIBOS_BADPWDMATCH; free(verify_data.data); } } } + if (!retval) + *size_return = k5prompt.reply->length; + else + memset(return_pwd, 0, *size_return); return retval; } #endif