summaryrefslogtreecommitdiff
path: root/crypto/bio/bio_lib.c
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/bio/bio_lib.c
parent2bdec3b037264540014120a02217fc67bf355f11 (diff)
downloadopenssl-new-afecd85db1359b5a62c037b8a507b928541c779c.tar.gz
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/bio/bio_lib.c')
-rw-r--r--crypto/bio/bio_lib.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c
index 5cdd6d7cfd..575107634c 100644
--- a/crypto/bio/bio_lib.c
+++ b/crypto/bio/bio_lib.c
@@ -870,7 +870,8 @@ int BIO_do_connect_retry(BIO *bio, int timeout, int nap_milliseconds)
BIO_set_nbio(bio, !blocking);
retry:
- rv = BIO_do_connect(bio); /* This may indirectly call ERR_clear_error(); */
+ ERR_set_mark();
+ rv = BIO_do_connect(bio);
if (rv <= 0) { /* could be timeout or retryable error or fatal error */
int err = ERR_peek_last_error();
@@ -897,7 +898,7 @@ int BIO_do_connect_retry(BIO *bio, int timeout, int nap_milliseconds)
}
}
if (timeout >= 0 && do_retry) {
- ERR_clear_error(); /* using ERR_pop_to_mark() would be cleaner */
+ ERR_pop_to_mark();
/* will not actually wait if timeout == 0 (i.e., blocking BIO): */
rv = bio_wait(bio, max_time, nap_milliseconds);
if (rv > 0)
@@ -905,11 +906,14 @@ int BIO_do_connect_retry(BIO *bio, int timeout, int nap_milliseconds)
ERR_raise(ERR_LIB_BIO,
rv == 0 ? BIO_R_CONNECT_TIMEOUT : BIO_R_CONNECT_ERROR);
} else {
+ ERR_clear_last_mark();
rv = -1;
if (err == 0) /* missing error queue entry */
/* workaround: general error */
ERR_raise(ERR_LIB_BIO, BIO_R_CONNECT_ERROR);
}
+ } else {
+ ERR_clear_last_mark();
}
return rv;