summaryrefslogtreecommitdiffstats
path: root/apps/ecparam.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2015-04-30 17:48:31 -0400
committerRich Salz <rsalz@openssl.org>2015-04-30 17:48:31 -0400
commit68dc682499ea3fe27d909c946d7abd39062d6efd (patch)
tree3478a6fb3699bdfa08d5871848696882ee1c24db /apps/ecparam.c
parent222561fe8ef510f336417a666f69f81ddc9b8fe4 (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/ecparam.c')
-rw-r--r--apps/ecparam.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/apps/ecparam.c b/apps/ecparam.c
index f316793cd3..5b39e83cd8 100644
--- a/apps/ecparam.c
+++ b/apps/ecparam.c
@@ -229,16 +229,10 @@ int ecparam_main(int argc, char **argv)
if (list_curves) {
EC_builtin_curve *curves = NULL;
- size_t crv_len = 0;
- size_t n = 0;
-
- crv_len = EC_get_builtin_curves(NULL, 0);
-
- curves = OPENSSL_malloc((int)(sizeof(EC_builtin_curve) * crv_len));
-
- if (curves == NULL)
- goto end;
+ size_t crv_len = EC_get_builtin_curves(NULL, 0);
+ size_t n;
+ curves = app_malloc((int)(sizeof *curves * crv_len), "list curves");
if (!EC_get_builtin_curves(curves, crv_len)) {
OPENSSL_free(curves);
goto end;
@@ -346,7 +340,7 @@ int ecparam_main(int argc, char **argv)
|| (ec_gen = BN_new()) == NULL
|| (ec_order = BN_new()) == NULL
|| (ec_cofactor = BN_new()) == NULL) {
- perror("OPENSSL_malloc");
+ perror("Can't allocate BN");
goto end;
}
@@ -388,11 +382,7 @@ int ecparam_main(int argc, char **argv)
if ((tmp_len = (size_t)BN_num_bytes(ec_cofactor)) > buf_len)
buf_len = tmp_len;
- buffer = OPENSSL_malloc(buf_len);
- if (buffer == NULL) {
- perror("OPENSSL_malloc");
- goto end;
- }
+ buffer = app_malloc(buf_len, "BN buffer");
BIO_printf(out, "EC_GROUP *get_ec_group_%d(void)\n{\n", len);
print_bignum_var(out, ec_p, "ec_p", len, buffer);