PR: 2090
authorDr. Stephen Henson <steve@openssl.org>
Tue, 10 Nov 2009 00:40:42 +0000 (00:40 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 10 Nov 2009 00:40:42 +0000 (00:40 +0000)
Submitted by: Martin Kaiser <lists@kaiser.cx>, Stephen Henson
Approved by: steve@openssl.org

Improve error checking in asn1_gen.c

crypto/asn1/asn1_gen.c

index 2da38292c8c59f46053f9ab127d5509308e4114b..b066dc9eae3a98a5fb4fcfdb16d8212a6998734e 100644 (file)
@@ -446,6 +446,8 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf)
        int derlen;
        int i, is_set;
        sk = sk_ASN1_TYPE_new_null();
+       if (!sk)
+               goto bad;
        if (section)
                {
                if (!cnf)
@@ -458,7 +460,8 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf)
                        typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);
                        if (!typ)
                                goto bad;
-                       sk_ASN1_TYPE_push(sk, typ);
+                       if (!sk_ASN1_TYPE_push(sk, typ))
+                               goto bad;
                        typ = NULL;
                        }
                }
@@ -474,6 +477,8 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf)
        derlen = i2d_ASN1_SET_OF_ASN1_TYPE(sk, NULL, i2d_ASN1_TYPE, utype,
                                           V_ASN1_UNIVERSAL, is_set);
        der = OPENSSL_malloc(derlen);
+       if (!der)
+               goto bad;
        p = der;
        i2d_ASN1_SET_OF_ASN1_TYPE(sk, &p, i2d_ASN1_TYPE, utype,
                                  V_ASN1_UNIVERSAL, is_set);