diff options
author | Tomas Mraz <tomas@openssl.org> | 2021-05-12 19:15:27 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-05-13 19:26:06 +0200 |
commit | afecd85db1359b5a62c037b8a507b928541c779c (patch) | |
tree | 26c1def792b0e9e80a8042ef87e9d5cfbc9093d1 /crypto/pkcs12 | |
parent | crypto/arm_arch.h: add a variable declaration (diff) | |
download | openssl-afecd85db1359b5a62c037b8a507b928541c779c.tar.xz openssl-afecd85db1359b5a62c037b8a507b928541c779c.zip |
Replace some of the ERR_clear_error() calls with mark calls
Fixes #15219
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/15253)
Diffstat (limited to 'crypto/pkcs12')
-rw-r--r-- | crypto/pkcs12/p12_add.c | 3 | ||||
-rw-r--r-- | crypto/pkcs12/p12_p8e.c | 22 |
2 files changed, 15 insertions, 10 deletions
diff --git a/crypto/pkcs12/p12_add.c b/crypto/pkcs12/p12_add.c index b644834f33..6fd4184af5 100644 --- a/crypto/pkcs12/p12_add.c +++ b/crypto/pkcs12/p12_add.c @@ -102,14 +102,15 @@ PKCS7 *PKCS12_pack_p7encdata_ex(int pbe_nid, const char *pass, int passlen, goto err; } + ERR_set_mark(); pbe_ciph = pbe_ciph_fetch = EVP_CIPHER_fetch(ctx, OBJ_nid2sn(pbe_nid), propq); if (pbe_ciph == NULL) pbe_ciph = EVP_get_cipherbynid(pbe_nid); + ERR_pop_to_mark(); if (pbe_ciph != NULL) { pbe = PKCS5_pbe2_set_iv_ex(pbe_ciph, iter, salt, saltlen, NULL, -1, ctx); } else { - ERR_clear_error(); pbe = PKCS5_pbe_set_ex(pbe_nid, iter, salt, saltlen, ctx); } diff --git a/crypto/pkcs12/p12_p8e.c b/crypto/pkcs12/p12_p8e.c index e357f310a6..9c27534017 100644 --- a/crypto/pkcs12/p12_p8e.c +++ b/crypto/pkcs12/p12_p8e.c @@ -29,16 +29,20 @@ X509_SIG *PKCS8_encrypt_ex(int pbe_nid, const EVP_CIPHER *cipher, } pbe = PKCS5_pbe2_set_iv_ex(cipher, iter, salt, saltlen, NULL, -1, libctx); - } else if (EVP_PBE_find(EVP_PBE_TYPE_PRF, pbe_nid, NULL, NULL, 0)) { - if (cipher == NULL) { - ERR_raise(ERR_LIB_PKCS12, ERR_R_PASSED_NULL_PARAMETER); - return NULL; - } - pbe = PKCS5_pbe2_set_iv_ex(cipher, iter, salt, saltlen, NULL, pbe_nid, - libctx); } else { - ERR_clear_error(); - pbe = PKCS5_pbe_set_ex(pbe_nid, iter, salt, saltlen, libctx); + ERR_set_mark(); + if (EVP_PBE_find(EVP_PBE_TYPE_PRF, pbe_nid, NULL, NULL, 0)) { + ERR_clear_last_mark(); + if (cipher == NULL) { + ERR_raise(ERR_LIB_PKCS12, ERR_R_PASSED_NULL_PARAMETER); + return NULL; + } + pbe = PKCS5_pbe2_set_iv_ex(cipher, iter, salt, saltlen, NULL, + pbe_nid, libctx); + } else { + ERR_pop_to_mark(); + pbe = PKCS5_pbe_set_ex(pbe_nid, iter, salt, saltlen, libctx); + } } if (pbe == NULL) { ERR_raise(ERR_LIB_PKCS12, ERR_R_ASN1_LIB); |