From 68dc682499ea3fe27d909c946d7abd39062d6efd Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Thu, 30 Apr 2015 17:48:31 -0400 Subject: 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 --- apps/ts.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'apps/ts.c') diff --git a/apps/ts.c b/apps/ts.c index e0f43130ca..3cfdc79e4e 100644 --- a/apps/ts.c +++ b/apps/ts.c @@ -576,10 +576,7 @@ static int create_digest(BIO *input, char *digest, const EVP_MD *md, unsigned char buffer[4096]; int length; - *md_value = OPENSSL_malloc(md_value_len); - if (*md_value == 0) - goto err; - + *md_value = app_malloc(md_value_len, "digest buffer"); EVP_DigestInit(&md_ctx, md); while ((length = BIO_read(input, buffer, sizeof(buffer))) > 0) { EVP_DigestUpdate(&md_ctx, buffer, length); @@ -624,8 +621,7 @@ static ASN1_INTEGER *create_nonce(int bits) OPENSSL_free(nonce->data); /* Allocate at least one byte. */ nonce->length = len - i; - if (!(nonce->data = OPENSSL_malloc(nonce->length + 1))) - goto err; + nonce->data = app_malloc(nonce->length + 1, "nonce buffer"); memcpy(nonce->data, buf + i, nonce->length); return nonce; -- cgit v1.2.3