RT4002: check for NULL cipher in p12_crpt.c
authorEmilia Kasper <emilia@openssl.org>
Tue, 1 Sep 2015 12:56:58 +0000 (14:56 +0200)
committerEmilia Kasper <emilia@openssl.org>
Tue, 1 Sep 2015 18:01:38 +0000 (20:01 +0200)
The NULL cipher case can't actually happen because we have no
EVP_PBE_CTL combinations where cipher_nid is -1 and keygen is
PKCS12_PBE_keyivgen. But make the code more obviously correct.

Reviewed-by: Matt Caswell <matt@openssl.org>
crypto/pkcs12/p12_crpt.c

index 08be40c61ffd486703e5f371cd1c4423af3174d8..e7d5ac9f6bd7317504b22b6091db8ce96bd173a0 100644 (file)
@@ -76,6 +76,9 @@ int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
     unsigned char *salt;
     unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH];
 
+    if (cipher == NULL)
+        return 0;
+
     /* Extract useful info from parameter */
 
     pbe = ASN1_TYPE_unpack_sequence(ASN1_ITEM_rptr(PBEPARAM), param);