For self signed root only indicate one error.
[openssl.git] / crypto / pem / pem_info.c
index 6e0ad72605fb42097f65b9d48de2770d68843469..cc7f24a9c1cf491ae3092b9dc4aa8fe05e927ef0 100644 (file)
@@ -99,7 +99,7 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pe
        int ok=0;
        STACK_OF(X509_INFO) *ret=NULL;
        unsigned int i,raw,ptype;
-       d2i_of_void *d2i;
+       d2i_of_void *d2i = 0;
 
        if (sk == NULL)
                {
@@ -167,6 +167,7 @@ start:
 #ifndef OPENSSL_NO_RSA
                        if (strcmp(name,PEM_STRING_RSA) == 0)
                        {
+                       d2i=(D2I_OF(void))d2i_RSAPrivateKey;
                        if (xi->x_pkey != NULL) 
                                {
                                if (!sk_X509_INFO_push(ret,xi)) goto err;
@@ -339,6 +340,12 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
                {
                if ( (xi->enc_data!=NULL) && (xi->enc_len>0) )
                        {
+                       if (enc == NULL)
+                               {
+                               PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO,PEM_R_CIPHER_IS_NULL);
+                               goto err;
+                               }
+
                        /* copy from weirdo names into more normal things */
                        iv=xi->enc_cipher.iv;
                        data=(unsigned char *)xi->enc_data;