wrowe 01/02/11 15:41:34
Modified: passwd apr_getpass.c
Log:
Finally, protect from pure bogosity
Revision Changes Path
1.14 +6 -4 apr/passwd/apr_getpass.c
Index: apr_getpass.c
===================================================================
RCS file: /home/cvs/apr/passwd/apr_getpass.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- apr_getpass.c 2001/02/11 23:35:07 1.13
+++ apr_getpass.c 2001/02/11 23:41:34 1.14
@@ -133,10 +133,10 @@
if (tcgetattr(STDIN_FILENO, &attr) != 0)
return NULL;
- attr.c_lflag &= ~(ECHO);
-
- if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &attr) != 0)
- return NULL;
+ attr.c_lflag &= ~(ECHO);
+
+ if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &attr) != 0)
+ return NULL;
while ((password[n] = getchar()) != '\n') {
if (password[n] >= ' ' && password[n] <= '~') {
n++;
@@ -215,6 +215,8 @@
APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf,
size_t *bufsiz)
{
char *pw_got = getpass(prompt);
+ if (!pw_got)
+ return APR_EINVAL;
apr_cpystrn(pwbuf, pw_got, *bufsiz);
memset(pw_got, 0, strlen(pw_got));
if (strlen(pw_got) >= *bufsiz) {