diff options
author | Rich Salz <rsalz@openssl.org> | 2015-04-30 17:48:31 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-04-30 17:48:31 -0400 |
commit | 68dc682499ea3fe27d909c946d7abd39062d6efd (patch) | |
tree | 3478a6fb3699bdfa08d5871848696882ee1c24db /apps/passwd.c | |
parent | 222561fe8ef510f336417a666f69f81ddc9b8fe4 (diff) |
In apps, malloc or die
No point in proceeding if you're out of memory. So change
*all* OPENSSL_malloc calls in apps to use the new routine which
prints a message and exits.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'apps/passwd.c')
-rw-r--r-- | apps/passwd.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/apps/passwd.c b/apps/passwd.c index 3c6fd5204e..c529792eed 100644 --- a/apps/passwd.c +++ b/apps/passwd.c @@ -221,12 +221,9 @@ int passwd_main(int argc, char **argv) /* no passwords on the command line */ passwd_malloc_size = pw_maxlen + 2; - /* - * longer than necessary so that we can warn about truncation - */ - passwd = passwd_malloc = OPENSSL_malloc(passwd_malloc_size); - if (passwd_malloc == NULL) - goto end; + /* longer than necessary so that we can warn about truncation */ + passwd = passwd_malloc = + app_malloc(passwd_malloc_size, "password buffer"); } if ((in == NULL) && (passwds == NULL)) { @@ -426,9 +423,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p, # ifndef OPENSSL_NO_DES if (usecrypt) { if (*salt_malloc_p == NULL) { - *salt_p = *salt_malloc_p = OPENSSL_malloc(3); - if (*salt_malloc_p == NULL) - goto end; + *salt_p = *salt_malloc_p = app_malloc(3, "salt buffer"); } if (RAND_bytes((unsigned char *)*salt_p, 2) <= 0) goto end; @@ -447,9 +442,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p, int i; if (*salt_malloc_p == NULL) { - *salt_p = *salt_malloc_p = OPENSSL_malloc(9); - if (*salt_malloc_p == NULL) - goto end; + *salt_p = *salt_malloc_p = app_malloc(9, "salt buffer"); } if (RAND_bytes((unsigned char *)*salt_p, 8) <= 0) goto end; |