diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2020-12-11 19:24:46 +1000 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-01-18 15:01:26 +0100 |
commit | 038f4dc68edd16f719ce5cf140eda2fb5b86a62a (patch) | |
tree | c91c66bd82817b4bd83810278bc5b0074854d69d /crypto/pkcs7/pk7_lib.c | |
parent | 84af8027c5f2132a9166673e7a47b0f31c7cfe1d (diff) | |
download | openssl-038f4dc68edd16f719ce5cf140eda2fb5b86a62a.tar.gz |
Fix PKCS7 potential segfault
As the code that handles libctx, propq for PKCS7 is very similar to CMS
code, a similiar fix for issue #13624 needs to be applied.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13668)
Diffstat (limited to 'crypto/pkcs7/pk7_lib.c')
-rw-r--r-- | crypto/pkcs7/pk7_lib.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/pkcs7/pk7_lib.c b/crypto/pkcs7/pk7_lib.c index 1cc233e89d..35a757062b 100644 --- a/crypto/pkcs7/pk7_lib.c +++ b/crypto/pkcs7/pk7_lib.c @@ -401,6 +401,8 @@ void pkcs7_resolve_libctx(PKCS7 *p7) { int i; const PKCS7_CTX *ctx = pkcs7_get0_ctx(p7); + OSSL_LIB_CTX *libctx = pkcs7_ctx_get0_libctx(ctx); + const char *propq = pkcs7_ctx_get0_propq(ctx); STACK_OF(PKCS7_RECIP_INFO) *rinfos = pkcs7_get_recipient_info(p7); STACK_OF(PKCS7_SIGNER_INFO) *sinfos = PKCS7_get_signer_info(p7); STACK_OF(X509) *certs = pkcs7_get_signer_certs(p7); @@ -409,12 +411,12 @@ void pkcs7_resolve_libctx(PKCS7 *p7) return; for (i = 0; i < sk_X509_num(certs); i++) - x509_set0_libctx(sk_X509_value(certs, i), ctx->libctx, ctx->propq); + x509_set0_libctx(sk_X509_value(certs, i), libctx, propq); for (i = 0; i < sk_PKCS7_RECIP_INFO_num(rinfos); i++) { PKCS7_RECIP_INFO *ri = sk_PKCS7_RECIP_INFO_value(rinfos, i); - x509_set0_libctx(ri->cert, ctx->libctx, ctx->propq); + x509_set0_libctx(ri->cert, libctx, propq); } for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(sinfos); i++) { |