Add a helper function for resetting SSL_get_error state.
We repeat this in a bunch of places. Change-Id: Iee2c95a13e1645453f101d8be4be9ac78d520387 Reviewed-on: https://boringssl-review.googlesource.com/13051 Reviewed-by: David Benjamin <davidben@google.com>
This commit is contained in:
+1
-3
@@ -236,9 +236,7 @@ int dtls1_check_timeout_num(SSL *ssl) {
|
||||
}
|
||||
|
||||
int DTLSv1_handle_timeout(SSL *ssl) {
|
||||
ssl->rwstate = SSL_NOTHING;
|
||||
/* Functions which use SSL_get_error must clear the error queue on entry. */
|
||||
ERR_clear_error();
|
||||
ssl_reset_error_state(ssl);
|
||||
|
||||
if (!SSL_is_dtls(ssl)) {
|
||||
return -1;
|
||||
|
||||
@@ -1946,6 +1946,9 @@ void ssl_set_client_disabled(SSL *ssl);
|
||||
|
||||
void ssl_get_current_time(const SSL *ssl, struct timeval *out_clock);
|
||||
|
||||
/* ssl_reset_error_state resets state for |SSL_get_error|. */
|
||||
void ssl_reset_error_state(SSL *ssl);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern C */
|
||||
|
||||
+10
-14
@@ -612,11 +612,16 @@ BIO *SSL_get_wbio(const SSL *ssl) {
|
||||
return ssl->wbio;
|
||||
}
|
||||
|
||||
int SSL_do_handshake(SSL *ssl) {
|
||||
void ssl_reset_error_state(SSL *ssl) {
|
||||
/* Functions which use |SSL_get_error| must reset I/O and error state on
|
||||
* entry. */
|
||||
ssl->rwstate = SSL_NOTHING;
|
||||
/* Functions which use SSL_get_error must clear the error queue on entry. */
|
||||
ERR_clear_error();
|
||||
ERR_clear_system_error();
|
||||
}
|
||||
|
||||
int SSL_do_handshake(SSL *ssl) {
|
||||
ssl_reset_error_state(ssl);
|
||||
|
||||
if (ssl->handshake_func == NULL) {
|
||||
OPENSSL_PUT_ERROR(SSL, SSL_R_CONNECTION_TYPE_NOT_SET);
|
||||
@@ -735,10 +740,7 @@ static int ssl_do_post_handshake(SSL *ssl) {
|
||||
}
|
||||
|
||||
static int ssl_read_impl(SSL *ssl, void *buf, int num, int peek) {
|
||||
ssl->rwstate = SSL_NOTHING;
|
||||
/* Functions which use SSL_get_error must clear the error queue on entry. */
|
||||
ERR_clear_error();
|
||||
ERR_clear_system_error();
|
||||
ssl_reset_error_state(ssl);
|
||||
|
||||
if (ssl->handshake_func == NULL) {
|
||||
OPENSSL_PUT_ERROR(SSL, SSL_R_UNINITIALIZED);
|
||||
@@ -784,10 +786,7 @@ int SSL_peek(SSL *ssl, void *buf, int num) {
|
||||
}
|
||||
|
||||
int SSL_write(SSL *ssl, const void *buf, int num) {
|
||||
ssl->rwstate = SSL_NOTHING;
|
||||
/* Functions which use SSL_get_error must clear the error queue on entry. */
|
||||
ERR_clear_error();
|
||||
ERR_clear_system_error();
|
||||
ssl_reset_error_state(ssl);
|
||||
|
||||
if (ssl->handshake_func == NULL) {
|
||||
OPENSSL_PUT_ERROR(SSL, SSL_R_UNINITIALIZED);
|
||||
@@ -815,10 +814,7 @@ int SSL_write(SSL *ssl, const void *buf, int num) {
|
||||
}
|
||||
|
||||
int SSL_shutdown(SSL *ssl) {
|
||||
ssl->rwstate = SSL_NOTHING;
|
||||
/* Functions which use SSL_get_error must clear the error queue on entry. */
|
||||
ERR_clear_error();
|
||||
ERR_clear_system_error();
|
||||
ssl_reset_error_state(ssl);
|
||||
|
||||
if (ssl->handshake_func == NULL) {
|
||||
OPENSSL_PUT_ERROR(SSL, SSL_R_UNINITIALIZED);
|
||||
|
||||
Reference in New Issue
Block a user