From 4815d09a66fcc2a3ecabae72d77e841265da2451 Mon Sep 17 00:00:00 2001 From: tb <> Date: Thu, 31 Jul 2025 02:10:55 +0000 Subject: Rewrite PKCS7_get_smimecap() to use d2i_X509_ALGORS() Since we finally found a use for i2d_X509_ALGORS(), make use of its sibling here. This avoids some ridiculous contortions in not quite peak muppet code (obviously this was a first test run for the grand finale in CMS). ok kenjiro --- src/lib/libcrypto/pkcs7/pk7_attr.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lib/libcrypto/pkcs7/pk7_attr.c b/src/lib/libcrypto/pkcs7/pk7_attr.c index 9a822eaecd..ceaba9138d 100644 --- a/src/lib/libcrypto/pkcs7/pk7_attr.c +++ b/src/lib/libcrypto/pkcs7/pk7_attr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk7_attr.c,v 1.19 2025/07/31 02:02:35 tb Exp $ */ +/* $OpenBSD: pk7_attr.c,v 1.20 2025/07/31 02:10:55 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -108,14 +108,17 @@ PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si) { ASN1_TYPE *cap; const unsigned char *p; + int len; - cap = PKCS7_get_signed_attribute(si, NID_SMIMECapabilities); - if (!cap || (cap->type != V_ASN1_SEQUENCE)) + if ((cap = PKCS7_get_signed_attribute(si, NID_SMIMECapabilities)) == NULL) return NULL; + if (cap->type != V_ASN1_SEQUENCE) + return NULL; + p = cap->value.sequence->data; - return (STACK_OF(X509_ALGOR) *) - ASN1_item_d2i(NULL, &p, cap->value.sequence->length, - &X509_ALGORS_it); + len = cap->value.sequence->length; + + return d2i_X509_ALGORS(NULL, &p, len); } LCRYPTO_ALIAS(PKCS7_get_smimecap); -- cgit v1.2.3-55-g6feb