Add malloc failure checks
authorMatt Caswell <matt@openssl.org>
Thu, 12 Mar 2015 11:10:47 +0000 (11:10 +0000)
committerMatt Caswell <matt@openssl.org>
Tue, 17 Mar 2015 13:39:53 +0000 (13:39 +0000)
Add some missing checks for memory allocation failures in ca app.

Reviewed-by: Tim Hudson <tjh@openssl.org>
apps/ca.c

index 814162d0b9dbf3d8e0433b0aa3b325af854a4b2d..9ef0ce31e6301e168db10dbc5f5acf3e8a58e8c8 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -2809,6 +2809,11 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
     ASN1_GENERALIZEDTIME *comp_time = NULL;
     tmp = BUF_strdup(str);
 
     ASN1_GENERALIZEDTIME *comp_time = NULL;
     tmp = BUF_strdup(str);
 
+    if(!tmp) {
+        BIO_printf(bio_err, "memory allocation failure\n");
+        goto err;
+    }
+
     p = strchr(tmp, ',');
 
     rtime_str = tmp;
     p = strchr(tmp, ',');
 
     rtime_str = tmp;
@@ -2826,6 +2831,10 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
 
     if (prevtm) {
         *prevtm = ASN1_UTCTIME_new();
 
     if (prevtm) {
         *prevtm = ASN1_UTCTIME_new();
+        if(!*prevtm) {
+            BIO_printf(bio_err, "memory allocation failure\n");
+            goto err;
+        }
         if (!ASN1_UTCTIME_set_string(*prevtm, rtime_str)) {
             BIO_printf(bio_err, "invalid revocation date %s\n", rtime_str);
             goto err;
         if (!ASN1_UTCTIME_set_string(*prevtm, rtime_str)) {
             BIO_printf(bio_err, "invalid revocation date %s\n", rtime_str);
             goto err;
@@ -2866,6 +2875,10 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
                 goto err;
             }
             comp_time = ASN1_GENERALIZEDTIME_new();
                 goto err;
             }
             comp_time = ASN1_GENERALIZEDTIME_new();
+            if(!comp_time) {
+                BIO_printf(bio_err, "memory allocation failure\n");
+                goto err;
+            }
             if (!ASN1_GENERALIZEDTIME_set_string(comp_time, arg_str)) {
                 BIO_printf(bio_err, "invalid compromised time %s\n", arg_str);
                 goto err;
             if (!ASN1_GENERALIZEDTIME_set_string(comp_time, arg_str)) {
                 BIO_printf(bio_err, "invalid compromised time %s\n", arg_str);
                 goto err;