summaryrefslogtreecommitdiffstats
path: root/apps/passwd.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2000-04-27 06:47:23 +0000
committerBodo Möller <bodo@openssl.org>2000-04-27 06:47:23 +0000
commit4adcfa052f0fcae35a92b9c7e0248d9c6586a6ca (patch)
treebd48e70d86c260113391bcd2d62854026d06f459 /apps/passwd.c
parent09451b6857e97b34daa5cfb1b44c5ada96c7f3e1 (diff)
Warn about truncation also in the case when a single password is read using
the password prompt.
Diffstat (limited to 'apps/passwd.c')
-rw-r--r--apps/passwd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/apps/passwd.c b/apps/passwd.c
index c7e21d2081..5a7c99abd4 100644
--- a/apps/passwd.c
+++ b/apps/passwd.c
@@ -196,7 +196,9 @@ int MAIN(int argc, char **argv)
if (passwds == NULL)
{
/* no passwords on the command line */
- passwd = passwd_malloc = Malloc(pw_maxlen + 1);
+#define PASSWD_MALLOC_SIZE (pw_maxlen + 2)
+ /* longer than necessary so that we can warn about truncation */
+ passwd = passwd_malloc = Malloc(PASSWD_MALLOC_SIZE);
if (passwd_malloc == NULL)
goto err;
}
@@ -208,7 +210,7 @@ int MAIN(int argc, char **argv)
passwds = passwds_static;
if (in == NULL)
- if (EVP_read_pw_string(passwd_malloc, pw_maxlen + 1, "Password: ", 0) != 0)
+ if (EVP_read_pw_string(passwd_malloc, PASSWD_MALLOC_SIZE, "Password: ", 0) != 0)
goto err;
passwds[0] = passwd_malloc;
}