summaryrefslogtreecommitdiff
path: root/passwd
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2001-02-11 23:41:34 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2001-02-11 23:41:34 +0000
commit79ba1c35ae2c22667b407655f81ad8b16462d9e3 (patch)
tree089948f6240a00c7f007f710c873ccda33736057 /passwd
parent6af76a0465247f1dcf72a67c2cf9a754c6b14a22 (diff)
downloadlibapr-79ba1c35ae2c22667b407655f81ad8b16462d9e3.tar.gz
Finally, protect from pure bogosity
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61221 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'passwd')
-rw-r--r--passwd/apr_getpass.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/passwd/apr_getpass.c b/passwd/apr_getpass.c
index 1004575af..836438488 100644
--- a/passwd/apr_getpass.c
+++ b/passwd/apr_getpass.c
@@ -133,10 +133,10 @@ static char *getpass(const char *prompt)
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 @@ static char *getpass(const char *prompt)
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) {