From 71d39bbee0a16bbcc6b1fe317c0b63a2617d48b9 Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 22 Aug 2023 08:59:44 +0000 Subject: [PATCH] Pull the NULL check for cmsbio into the switch ok jsing --- lib/libcrypto/cms/cms_lib.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/libcrypto/cms/cms_lib.c b/lib/libcrypto/cms/cms_lib.c index 9f8e13d36fe..fc899437ab7 100644 --- a/lib/libcrypto/cms/cms_lib.c +++ b/lib/libcrypto/cms/cms_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_lib.c,v 1.20 2023/08/22 08:44:15 tb Exp $ */ +/* $OpenBSD: cms_lib.c,v 1.21 2023/08/22 08:59:44 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -152,35 +152,31 @@ CMS_dataInit(CMS_ContentInfo *cms, BIO *icont) CMSerror(CMS_R_NO_CONTENT); goto err; } - switch (OBJ_obj2nid(cms->contentType)) { + switch (OBJ_obj2nid(cms->contentType)) { case NID_pkcs7_data: return cont; - case NID_pkcs7_signed: - cmsbio = cms_SignedData_init_bio(cms); + if ((cmsbio = cms_SignedData_init_bio(cms)) == NULL) + goto err; break; - case NID_pkcs7_digest: - cmsbio = cms_DigestedData_init_bio(cms); + if ((cmsbio = cms_DigestedData_init_bio(cms)) == NULL) + goto err; break; - case NID_pkcs7_encrypted: - cmsbio = cms_EncryptedData_init_bio(cms); + if ((cmsbio = cms_EncryptedData_init_bio(cms)) == NULL) + goto err; break; - case NID_pkcs7_enveloped: - cmsbio = cms_EnvelopedData_init_bio(cms); + if ((cmsbio = cms_EnvelopedData_init_bio(cms)) == NULL) + goto err; break; - default: CMSerror(CMS_R_UNSUPPORTED_TYPE); goto err; } - if (cmsbio == NULL) - goto err; - return BIO_push(cmsbio, cont); err: -- 2.20.1