From 2fcabfbada29b18afd6d34addaca6622cbf1cd17 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Mon, 5 Feb 1990 14:39:26 +0000 Subject: [PATCH] need to fill in return length (also change to int *) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@272 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/read_pwd.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/lib/krb5/os/read_pwd.c b/src/lib/krb5/os/read_pwd.c index 06ea5ccc4..357a780e8 100644 --- a/src/lib/krb5/os/read_pwd.c +++ b/src/lib/krb5/os/read_pwd.c @@ -53,7 +53,7 @@ krb5_read_password(prompt, prompt2, return_pwd, size_return) char *prompt; char *prompt2; char *return_pwd; -int size_return; +int *size_return; { /* adapted from Kerberos v4 des/read_password.c */ @@ -76,10 +76,10 @@ int size_return; if (setjmp(pwd_jump)) { /* interrupted */ if (readin_string) { - (void) bzero(readin_string, size_return); + (void) bzero(readin_string, *size_return); free(readin_string); } - (void) bzero(return_pwd, size_return); + (void) bzero(return_pwd, *size_return); cleanup(KRB5_LIBOS_PWDINTR); } /* save intrfunc */ @@ -88,11 +88,11 @@ int size_return; /* put out the prompt */ (void) fputs(prompt,stdout); (void) fflush(stdout); - (void) bzero(return_pwd, size_return); + (void) bzero(return_pwd, *size_return); - if (fgets(return_pwd, size_return, stdin) == NULL) { + if (fgets(return_pwd, *size_return, stdin) == NULL) { /* error */ - (void) bzero(return_pwd, size_return); + (void) bzero(return_pwd, *size_return); cleanup(KRB5_LIBOS_CANTREADPWD); } /* fgets always null-terminates the returned string */ @@ -110,33 +110,34 @@ int size_return; (void) putchar('\n'); (void) fputs(prompt2,stdout); (void) fflush(stdout); - readin_string = malloc(size_return); + readin_string = malloc(*size_return); if (!readin_string) { - (void) bzero(return_pwd, size_return); + (void) bzero(return_pwd, *size_return); cleanup(ENOMEM); } - (void) bzero(readin_string, size_return); - if (fgets(readin_string, size_return, stdin) == NULL) { + (void) bzero(readin_string, *size_return); + if (fgets(readin_string, *size_return, stdin) == NULL) { /* error */ - (void) bzero(readin_string, size_return); - (void) bzero(return_pwd, size_return); + (void) bzero(readin_string, *size_return); + (void) bzero(return_pwd, *size_return); free(readin_string); cleanup(KRB5_LIBOS_CANTREADPWD); } if (ptr = index(readin_string, '\n')) *ptr = '\0'; - else /* need to flush */ + else /* need to flush */ do { scratchchar = getchar(); } while (scratchchar != EOF && scratchchar != '\n'); + /* compare */ - if (strncmp(return_pwd, readin_string, size_return)) { - (void) bzero(readin_string, size_return); - (void) bzero(return_pwd, size_return); + if (strncmp(return_pwd, readin_string, *size_return)) { + (void) bzero(readin_string, *size_return); + (void) bzero(return_pwd, *size_return); free(readin_string); cleanup(KRB5_LIBOS_BADPWDMATCH); } - (void) bzero(readin_string, size_return); + (void) bzero(readin_string, *size_return); free(readin_string); } @@ -146,6 +147,7 @@ int size_return; if (ioctl(0, TIOCSETP, (char *)&tty_savestate) == -1) return errno; + *size_return = strlen(return_pwd); return 0; } -- 2.26.2