summaryrefslogtreecommitdiffstats
path: root/crypto/asn1
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-05-12 19:15:27 +0200
committerTomas Mraz <tomas@openssl.org>2021-05-13 19:26:06 +0200
commitafecd85db1359b5a62c037b8a507b928541c779c (patch)
tree26c1def792b0e9e80a8042ef87e9d5cfbc9093d1 /crypto/asn1
parent2bdec3b037264540014120a02217fc67bf355f11 (diff)
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/asn1')
-rw-r--r--crypto/asn1/a_d2i_fp.c7
-rw-r--r--crypto/asn1/p5_pbev2.c3
2 files changed, 6 insertions, 4 deletions
diff --git a/crypto/asn1/a_d2i_fp.c b/crypto/asn1/a_d2i_fp.c
index 2c7acb34e0..f1e96b2eaf 100644
--- a/crypto/asn1/a_d2i_fp.c
+++ b/crypto/asn1/a_d2i_fp.c
@@ -115,7 +115,7 @@ int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
return -1;
}
- ERR_clear_error();
+ ERR_set_mark();
for (;;) {
diff = len - off;
if (want >= diff) {
@@ -149,10 +149,10 @@ int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
if (inf & 0x80) {
unsigned long e;
- e = ERR_GET_REASON(ERR_peek_error());
+ e = ERR_GET_REASON(ERR_peek_last_error());
if (e != ASN1_R_TOO_LONG)
goto err;
- ERR_clear_error();
+ ERR_pop_to_mark();
}
i = q - p; /* header length */
off += i; /* end of data */
@@ -235,6 +235,7 @@ int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
*pb = b;
return off;
err:
+ ERR_clear_last_mark();
BUF_MEM_free(b);
return -1;
}
diff --git a/crypto/asn1/p5_pbev2.c b/crypto/asn1/p5_pbev2.c
index da227b96e2..c9d9d31cc2 100644
--- a/crypto/asn1/p5_pbev2.c
+++ b/crypto/asn1/p5_pbev2.c
@@ -88,11 +88,12 @@ X509_ALGOR *PKCS5_pbe2_set_iv_ex(const EVP_CIPHER *cipher, int iter,
* If prf NID unspecified see if cipher has a preference. An error is OK
* here: just means use default PRF.
*/
+ ERR_set_mark();
if ((prf_nid == -1) &&
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_PBE_PRF_NID, 0, &prf_nid) <= 0) {
- ERR_clear_error();
prf_nid = NID_hmacWithSHA256;
}
+ ERR_pop_to_mark();
EVP_CIPHER_CTX_free(ctx);
ctx = NULL;