summaryrefslogtreecommitdiffstats
path: root/apps/ts.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/ts.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/ts.c')
-rw-r--r--apps/ts.c8
1 files changed, 2 insertions, 6 deletions
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;