diff --git a/ssl/d1_pkt.cc b/ssl/d1_pkt.cc index d9496d9b..92a9663e 100644 --- a/ssl/d1_pkt.cc +++ b/ssl/d1_pkt.cc @@ -130,7 +130,7 @@ namespace bssl { int dtls1_get_record(SSL *ssl) { again: - switch (ssl->s3->recv_shutdown) { + switch (ssl->s3->read_shutdown) { case ssl_shutdown_none: break; case ssl_shutdown_fatal_alert: @@ -291,8 +291,8 @@ void dtls1_read_close_notify(SSL *ssl) { // alerts also aren't delivered reliably, so we may even time out because the // peer never received our close_notify. Report to the caller that the channel // has fully shut down. - if (ssl->s3->recv_shutdown == ssl_shutdown_none) { - ssl->s3->recv_shutdown = ssl_shutdown_close_notify; + if (ssl->s3->read_shutdown == ssl_shutdown_none) { + ssl->s3->read_shutdown = ssl_shutdown_close_notify; } } diff --git a/ssl/internal.h b/ssl/internal.h index 36d33902..93864acd 100644 --- a/ssl/internal.h +++ b/ssl/internal.h @@ -1754,12 +1754,11 @@ struct SSL3_STATE { int wpend_ret; // number of bytes submitted const uint8_t *wpend_buf; - // recv_shutdown is the shutdown state for the receive half of the - // connection. - enum ssl_shutdown_t recv_shutdown; + // read_shutdown is the shutdown state for the read half of the connection. + enum ssl_shutdown_t read_shutdown; - // recv_shutdown is the shutdown state for the send half of the connection. - enum ssl_shutdown_t send_shutdown; + // write_shutdown is the shutdown state for the write half of the connection. + enum ssl_shutdown_t write_shutdown; int alert_dispatch; diff --git a/ssl/s3_pkt.cc b/ssl/s3_pkt.cc index 48de23f1..8911c98e 100644 --- a/ssl/s3_pkt.cc +++ b/ssl/s3_pkt.cc @@ -131,7 +131,7 @@ static int do_ssl3_write(SSL *ssl, int type, const uint8_t *buf, unsigned len); // more data is needed. static int ssl3_get_record(SSL *ssl) { again: - switch (ssl->s3->recv_shutdown) { + switch (ssl->s3->read_shutdown) { case ssl_shutdown_none: break; case ssl_shutdown_fatal_alert: @@ -536,17 +536,17 @@ int ssl3_read_handshake_bytes(SSL *ssl, uint8_t *buf, int len) { int ssl3_send_alert(SSL *ssl, int level, int desc) { // It is illegal to send an alert when we've already sent a closing one. - if (ssl->s3->send_shutdown != ssl_shutdown_none) { + if (ssl->s3->write_shutdown != ssl_shutdown_none) { OPENSSL_PUT_ERROR(SSL, SSL_R_PROTOCOL_IS_SHUTDOWN); return -1; } if (level == SSL3_AL_WARNING && desc == SSL_AD_CLOSE_NOTIFY) { - ssl->s3->send_shutdown = ssl_shutdown_close_notify; + ssl->s3->write_shutdown = ssl_shutdown_close_notify; } else { assert(level == SSL3_AL_FATAL); assert(desc != SSL_AD_CLOSE_NOTIFY); - ssl->s3->send_shutdown = ssl_shutdown_fatal_alert; + ssl->s3->write_shutdown = ssl_shutdown_fatal_alert; } ssl->s3->alert_dispatch = 1; diff --git a/ssl/ssl_lib.cc b/ssl/ssl_lib.cc index 89eb6fe9..528263d7 100644 --- a/ssl/ssl_lib.cc +++ b/ssl/ssl_lib.cc @@ -978,7 +978,7 @@ int SSL_write(SSL *ssl, const void *buf, int num) { return -1; } - if (ssl->s3->send_shutdown != ssl_shutdown_none) { + if (ssl->s3->write_shutdown != ssl_shutdown_none) { OPENSSL_PUT_ERROR(SSL, SSL_R_PROTOCOL_IS_SHUTDOWN); return -1; } @@ -1021,8 +1021,8 @@ int SSL_shutdown(SSL *ssl) { if (ssl->quiet_shutdown) { // Do nothing if configured not to send a close_notify. - ssl->s3->send_shutdown = ssl_shutdown_close_notify; - ssl->s3->recv_shutdown = ssl_shutdown_close_notify; + ssl->s3->write_shutdown = ssl_shutdown_close_notify; + ssl->s3->read_shutdown = ssl_shutdown_close_notify; return 1; } @@ -1030,7 +1030,7 @@ int SSL_shutdown(SSL *ssl) { // waits for a close_notify to come in. Perform exactly one action and return // whether or not it succeeds. - if (ssl->s3->send_shutdown != ssl_shutdown_close_notify) { + if (ssl->s3->write_shutdown != ssl_shutdown_close_notify) { // Send a close_notify. if (ssl3_send_alert(ssl, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY) <= 0) { return -1; @@ -1040,16 +1040,16 @@ int SSL_shutdown(SSL *ssl) { if (ssl->method->dispatch_alert(ssl) <= 0) { return -1; } - } else if (ssl->s3->recv_shutdown != ssl_shutdown_close_notify) { + } else if (ssl->s3->read_shutdown != ssl_shutdown_close_notify) { // Wait for the peer's close_notify. ssl->method->read_close_notify(ssl); - if (ssl->s3->recv_shutdown != ssl_shutdown_close_notify) { + if (ssl->s3->read_shutdown != ssl_shutdown_close_notify) { return -1; } } // Return 0 for unidirectional shutdown and 1 for bidirectional shutdown. - return ssl->s3->recv_shutdown == ssl_shutdown_close_notify; + return ssl->s3->read_shutdown == ssl_shutdown_close_notify; } int SSL_send_fatal_alert(SSL *ssl, uint8_t alert) { @@ -1137,7 +1137,7 @@ int SSL_get_error(const SSL *ssl, int ret_code) { } if (ret_code == 0) { - if (ssl->s3->recv_shutdown == ssl_shutdown_close_notify) { + if (ssl->s3->read_shutdown == ssl_shutdown_close_notify) { return SSL_ERROR_ZERO_RETURN; } // An EOF was observed which violates the protocol, and the underlying @@ -2091,24 +2091,24 @@ void SSL_set_shutdown(SSL *ssl, int mode) { assert((SSL_get_shutdown(ssl) & mode) == SSL_get_shutdown(ssl)); if (mode & SSL_RECEIVED_SHUTDOWN && - ssl->s3->recv_shutdown == ssl_shutdown_none) { - ssl->s3->recv_shutdown = ssl_shutdown_close_notify; + ssl->s3->read_shutdown == ssl_shutdown_none) { + ssl->s3->read_shutdown = ssl_shutdown_close_notify; } if (mode & SSL_SENT_SHUTDOWN && - ssl->s3->send_shutdown == ssl_shutdown_none) { - ssl->s3->send_shutdown = ssl_shutdown_close_notify; + ssl->s3->write_shutdown == ssl_shutdown_none) { + ssl->s3->write_shutdown = ssl_shutdown_close_notify; } } int SSL_get_shutdown(const SSL *ssl) { int ret = 0; - if (ssl->s3->recv_shutdown != ssl_shutdown_none) { + if (ssl->s3->read_shutdown != ssl_shutdown_none) { // Historically, OpenSSL set |SSL_RECEIVED_SHUTDOWN| on both close_notify // and fatal alert. ret |= SSL_RECEIVED_SHUTDOWN; } - if (ssl->s3->send_shutdown == ssl_shutdown_close_notify) { + if (ssl->s3->write_shutdown == ssl_shutdown_close_notify) { // Historically, OpenSSL set |SSL_SENT_SHUTDOWN| on only close_notify. ret |= SSL_SENT_SHUTDOWN; } diff --git a/ssl/tls_record.cc b/ssl/tls_record.cc index b70e4f5d..73a8869c 100644 --- a/ssl/tls_record.cc +++ b/ssl/tls_record.cc @@ -535,7 +535,7 @@ enum ssl_open_record_t ssl_process_alert(SSL *ssl, uint8_t *out_alert, if (alert_level == SSL3_AL_WARNING) { if (alert_descr == SSL_AD_CLOSE_NOTIFY) { - ssl->s3->recv_shutdown = ssl_shutdown_close_notify; + ssl->s3->read_shutdown = ssl_shutdown_close_notify; return ssl_open_record_close_notify; } @@ -557,7 +557,7 @@ enum ssl_open_record_t ssl_process_alert(SSL *ssl, uint8_t *out_alert, } if (alert_level == SSL3_AL_FATAL) { - ssl->s3->recv_shutdown = ssl_shutdown_fatal_alert; + ssl->s3->read_shutdown = ssl_shutdown_fatal_alert; char tmp[16]; OPENSSL_PUT_ERROR(SSL, SSL_AD_REASON_OFFSET + alert_descr);