wrowe 01/02/11 15:35:07
Modified: passwd apr_getpass.c
Log:
Still wasn't right. Always return the (partial/complete) password
string, and use the apr_status_t as the -one and only- indicatator of
success, partial success or failure.
Revision Changes Path
1.13 +3 -5 apr/passwd/apr_getpass.c
Index: apr_getpass.c
===================================================================
RCS file: /home/cvs/apr/passwd/apr_getpass.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- apr_getpass.c 2001/02/11 23:32:11 1.12
+++ apr_getpass.c 2001/02/11 23:35:07 1.13
@@ -215,12 +215,10 @@
APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf,
size_t *bufsiz)
{
char *pw_got = getpass(prompt);
- if (strlen(pw_got) > (*bufsiz - 1)) {
- *bufsiz = ERR_OVERFLOW;
- memset(pw_got, 0, strlen(pw_got));
- return APR_ENAMETOOLONG;
- }
apr_cpystrn(pwbuf, pw_got, *bufsiz);
memset(pw_got, 0, strlen(pw_got));
+ if (strlen(pw_got) >= *bufsiz) {
+ return APR_ENAMETOOLONG;
+ }
return APR_SUCCESS;
}