Check return value from EVP_CIPHER_CTX_new in cms_pwri.c
authorinoguchi <inoguchi@openbsd.org>
Wed, 19 Jan 2022 13:47:44 +0000 (13:47 +0000)
committerinoguchi <inoguchi@openbsd.org>
Wed, 19 Jan 2022 13:47:44 +0000 (13:47 +0000)
CID 345137

ok jsing@ tb@

lib/libcrypto/cms/cms_pwri.c

index cf28dfc..eb241a6 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: cms_pwri.c,v 1.26 2019/08/12 18:04:57 jsing Exp $ */
+/* $OpenBSD: cms_pwri.c,v 1.27 2022/01/19 13:47:44 inoguchi Exp $ */
 /*
  * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project.
@@ -126,7 +126,9 @@ CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter, int wrap_nid,
        if (encalg == NULL) {
                goto merr;
        }
-       ctx = EVP_CIPHER_CTX_new();
+
+       if ((ctx = EVP_CIPHER_CTX_new()) == NULL)
+               goto merr;
 
        if (EVP_EncryptInit_ex(ctx, kekciph, NULL, NULL, NULL) <= 0) {
                CMSerror(ERR_R_EVP_LIB);