]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
asn_mime: Harden SMIME_write_ASN1_ex() against an empty stack
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sat, 11 Oct 2025 12:27:52 +0000 (20:27 +0800)
committerTomas Mraz <tomas@openssl.org>
Tue, 18 Nov 2025 16:53:40 +0000 (17:53 +0100)
Label an empty digest list as `signed-data` instead of `certs-only`.

Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28881)

crypto/asn1/asn_mime.c

index f3511fedd7de604301c084cd35d491f890b06bbc..c72aca06a6fa5830fa91b5c1ad538727589cfc62 100644 (file)
@@ -333,7 +333,7 @@ int SMIME_write_ASN1_ex(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
     } else if (ctype_nid == NID_pkcs7_signed) {
         if (econt_nid == NID_id_smime_ct_receipt)
             msg_type = "signed-receipt";
-        else if (sk_X509_ALGOR_num(mdalgs) >= 0)
+        else if (mdalgs != NULL && sk_X509_ALGOR_num(mdalgs) > 0)
             msg_type = "signed-data";
         else
             msg_type = "certs-only";