From: Matt Caswell Date: Thu, 3 Sep 2020 13:55:08 +0000 (+0100) Subject: Fix safestack issues in cms.h X-Git-Tag: openssl-3.0.0-alpha7~264 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=904e1f92b381a15139af154ca58fd6d9f566ab2e;p=thirdparty%2Fopenssl.git Fix safestack issues in cms.h Reviewed-by: Richard Levitte Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/12781) --- diff --git a/.gitignore b/.gitignore index edf56c7f3fa..f0c19f434fd 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ /include/crypto/*_conf.h /include/openssl/asn1.h /include/openssl/cmp.h +/include/openssl/cms.h /include/openssl/configuration.h /include/openssl/fipskey.h /include/openssl/opensslv.h diff --git a/apps/cms.c b/apps/cms.c index 2706e5af86b..178c441f1ab 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -23,8 +23,6 @@ # include # include -DEFINE_STACK_OF(CMS_SignerInfo) - static int save_certs(char *signerfile, STACK_OF(X509) *signers); static int cms_cb(int ok, X509_STORE_CTX *ctx); static void receipt_request_print(CMS_ContentInfo *cms); diff --git a/build.info b/build.info index 97b882af7f7..8729d6c5aa8 100644 --- a/build.info +++ b/build.info @@ -15,6 +15,7 @@ DEPEND[libssl]=libcrypto # unconditionally before anything else. DEPEND[]=include/openssl/asn1.h \ include/openssl/cmp.h \ + include/openssl/cms.h \ include/openssl/configuration.h \ include/openssl/fipskey.h \ include/openssl/opensslv.h \ @@ -28,6 +29,7 @@ DEPEND[]=include/openssl/asn1.h \ GENERATE[include/openssl/asn1.h]=include/openssl/asn1.h.in GENERATE[include/openssl/configuration.h]=include/openssl/configuration.h.in GENERATE[include/openssl/cmp.h]=include/openssl/cmp.h.in +GENERATE[include/openssl/cms.h]=include/openssl/cms.h.in GENERATE[include/openssl/fipskey.h]=include/openssl/fipskey.h.in GENERATE[include/openssl/opensslv.h]=include/openssl/opensslv.h.in GENERATE[include/openssl/safestack.h]=include/openssl/safestack.h.in diff --git a/crypto/cms/cms_env.c b/crypto/cms/cms_env.c index f0c895704f4..068696586e8 100644 --- a/crypto/cms/cms_env.c +++ b/crypto/cms/cms_env.c @@ -19,9 +19,6 @@ #include "crypto/x509.h" #include "cms_local.h" -DEFINE_STACK_OF(CMS_RecipientInfo) -DEFINE_STACK_OF(CMS_RevocationInfoChoice) - /* CMS EnvelopedData Utilities */ static void cms_env_set_version(CMS_EnvelopedData *env); diff --git a/crypto/cms/cms_ess.c b/crypto/cms/cms_ess.c index df2ab07f737..9903c444fa6 100644 --- a/crypto/cms/cms_ess.c +++ b/crypto/cms/cms_ess.c @@ -20,7 +20,6 @@ #include "crypto/x509.h" #include "cms_local.h" -DEFINE_STACK_OF(CMS_SignerInfo) DEFINE_STACK_OF(ESS_CERT_ID) DEFINE_STACK_OF(ESS_CERT_ID_V2) diff --git a/crypto/cms/cms_kari.c b/crypto/cms/cms_kari.c index b5d85b7d673..82a03e6c6bb 100644 --- a/crypto/cms/cms_kari.c +++ b/crypto/cms/cms_kari.c @@ -23,8 +23,6 @@ #include "cms_local.h" #include "crypto/asn1.h" -DEFINE_STACK_OF(CMS_RecipientEncryptedKey) - /* Key Agreement Recipient Info (KARI) routines */ int CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri, diff --git a/crypto/cms/cms_lib.c b/crypto/cms/cms_lib.c index 0b9a3f2b2f2..bc7da7ff94b 100644 --- a/crypto/cms/cms_lib.c +++ b/crypto/cms/cms_lib.c @@ -21,8 +21,6 @@ static STACK_OF(CMS_CertificateChoices) **cms_get0_certificate_choices(CMS_ContentInfo *cms); -DEFINE_STACK_OF(CMS_RevocationInfoChoice) - IMPLEMENT_ASN1_PRINT_FUNCTION(CMS_ContentInfo) CMS_ContentInfo *d2i_CMS_ContentInfo(CMS_ContentInfo **a, diff --git a/crypto/cms/cms_pwri.c b/crypto/cms/cms_pwri.c index e281bd72f22..0393608fdb1 100644 --- a/crypto/cms/cms_pwri.c +++ b/crypto/cms/cms_pwri.c @@ -18,8 +18,6 @@ #include "cms_local.h" #include "crypto/asn1.h" -DEFINE_STACK_OF(CMS_RecipientInfo) - int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, unsigned char *pass, ossl_ssize_t passlen) { diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c index e76766bab72..4b6822f4fd2 100644 --- a/crypto/cms/cms_sd.c +++ b/crypto/cms/cms_sd.c @@ -22,9 +22,6 @@ #include "crypto/ess.h" #include "crypto/x509.h" /* for X509_add_cert_new() */ -DEFINE_STACK_OF(CMS_RevocationInfoChoice) -DEFINE_STACK_OF(CMS_SignerInfo) - /* CMS SignedData Utilities */ static CMS_SignedData *cms_get0_signed(CMS_ContentInfo *cms) diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c index b2287c624d4..a50eee9fa97 100644 --- a/crypto/cms/cms_smime.c +++ b/crypto/cms/cms_smime.c @@ -16,10 +16,6 @@ #include "cms_local.h" #include "crypto/asn1.h" -DEFINE_STACK_OF(CMS_SignerInfo) -DEFINE_STACK_OF(CMS_RecipientEncryptedKey) -DEFINE_STACK_OF(CMS_RecipientInfo) - static BIO *cms_get_text_bio(BIO *out, unsigned int flags) { BIO *rbio; diff --git a/include/openssl/cms.h b/include/openssl/cms.h.in similarity index 98% rename from include/openssl/cms.h rename to include/openssl/cms.h.in index ad6718dd6f2..f89cbf96e7e 100644 --- a/include/openssl/cms.h +++ b/include/openssl/cms.h.in @@ -1,4 +1,6 @@ /* + * {- join("\n * ", @autowarntext) -} + * * Copyright 2008-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use @@ -7,6 +9,10 @@ * https://www.openssl.org/source/license.html */ +{- +use OpenSSL::stackhash qw(generate_stack_macros); +-} + #ifndef OPENSSL_CMS_H # define OPENSSL_CMS_H # pragma once @@ -36,10 +42,12 @@ typedef struct CMS_Receipt_st CMS_Receipt; typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey; typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute; -DEFINE_OR_DECLARE_STACK_OF(CMS_SignerInfo) -DEFINE_OR_DECLARE_STACK_OF(CMS_RecipientEncryptedKey) -DEFINE_OR_DECLARE_STACK_OF(CMS_RecipientInfo) -DEFINE_OR_DECLARE_STACK_OF(CMS_RevocationInfoChoice) +{- + generate_stack_macros("CMS_SignerInfo") + .generate_stack_macros("CMS_RecipientEncryptedKey") + .generate_stack_macros("CMS_RecipientInfo") + .generate_stack_macros("CMS_RevocationInfoChoice"); +-} DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)