diff options
Diffstat (limited to 'src/lib/libcrypto/ts/ts_rsp_sign.c')
-rw-r--r-- | src/lib/libcrypto/ts/ts_rsp_sign.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/lib/libcrypto/ts/ts_rsp_sign.c b/src/lib/libcrypto/ts/ts_rsp_sign.c index d35f6a7c94..b8cc7e2baf 100644 --- a/src/lib/libcrypto/ts/ts_rsp_sign.c +++ b/src/lib/libcrypto/ts/ts_rsp_sign.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ts_rsp_sign.c,v 1.36 2025/05/10 05:54:39 tb Exp $ */ | 1 | /* $OpenBSD: ts_rsp_sign.c,v 1.37 2025/07/31 02:02:35 tb Exp $ */ |
2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL | 2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL |
3 | * project 2002. | 3 | * project 2002. |
4 | */ | 4 | */ |
@@ -955,28 +955,32 @@ static int | |||
955 | ESS_add_signing_cert(PKCS7_SIGNER_INFO *si, ESS_SIGNING_CERT *sc) | 955 | ESS_add_signing_cert(PKCS7_SIGNER_INFO *si, ESS_SIGNING_CERT *sc) |
956 | { | 956 | { |
957 | ASN1_STRING *seq = NULL; | 957 | ASN1_STRING *seq = NULL; |
958 | unsigned char *p, *pp = NULL; | 958 | unsigned char *data = NULL; |
959 | int len; | 959 | int len = 0; |
960 | int ret = 0; | ||
960 | 961 | ||
961 | len = i2d_ESS_SIGNING_CERT(sc, NULL); | 962 | if ((len = i2d_ESS_SIGNING_CERT(sc, &data)) <= 0) { |
962 | if (!(pp = malloc(len))) { | 963 | len = 0; |
963 | TSerror(ERR_R_MALLOC_FAILURE); | ||
964 | goto err; | 964 | goto err; |
965 | } | 965 | } |
966 | p = pp; | 966 | |
967 | i2d_ESS_SIGNING_CERT(sc, &p); | 967 | if ((seq = ASN1_STRING_new()) == NULL) |
968 | if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set(seq, pp, len)) { | ||
969 | TSerror(ERR_R_MALLOC_FAILURE); | ||
970 | goto err; | 968 | goto err; |
971 | } | ||
972 | free(pp); | ||
973 | pp = NULL; | ||
974 | return PKCS7_add_signed_attribute(si, | ||
975 | NID_id_smime_aa_signingCertificate, V_ASN1_SEQUENCE, seq); | ||
976 | 969 | ||
977 | err: | 970 | ASN1_STRING_set0(seq, data, len); |
971 | data = NULL; | ||
972 | len = 0; | ||
973 | |||
974 | if (!PKCS7_add_signed_attribute(si, NID_id_smime_aa_signingCertificate, | ||
975 | V_ASN1_SEQUENCE, seq)) | ||
976 | goto err; | ||
977 | seq = NULL; | ||
978 | |||
979 | ret = 1; | ||
980 | |||
981 | err: | ||
978 | ASN1_STRING_free(seq); | 982 | ASN1_STRING_free(seq); |
979 | free(pp); | 983 | freezero(data, len); |
980 | 984 | ||
981 | return 0; | 985 | return ret; |
982 | } | 986 | } |