Eliminate memory leaks in mem_dbg.c.
[openssl.git] / crypto / pkcs7 / pk7_lib.c
index 889fb9b3553ba192c1b6af1995f2b4ba910accec..45973fe8507cc3d08be0efeebea9446697873ac3 100644 (file)
@@ -438,6 +438,7 @@ X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si)
 int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher)
        {
        int i;
+       ASN1_OBJECT *objtmp;
        PKCS7_ENC_CONTENT *ec;
 
        i=OBJ_obj2nid(p7->type);
@@ -454,7 +455,13 @@ int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher)
                return(0);
                }
 
-       /* Setup cipher OID */
+       /* Check cipher OID exists and has data in it*/
+       i = EVP_CIPHER_type(cipher);
+       if(i == NID_undef) {
+               PKCS7err(PKCS7_F_PKCS7_SET_CIPHER,PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER);
+               return(0);
+       }
+       objtmp = OBJ_nid2obj(i);
 
        ec->cipher = cipher;
        return 1;