From 2a08c8d85d9c99d1548da67627e5320646eae44f Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Tue, 7 Jun 2016 15:06:39 -0400 Subject: [PATCH] Remove ssl3_do_write's 0 case. It's unreachable and wouldn't work anyway. We'd never bubble up to the caller to retry. As a consequence, the TLS side doesn't actually need to pay attention to init_off. (For now anyway. We'll probably need state of this sort once the write half is all reworked. All the craziness with wpend_buf ought to be limited to the SSL_write bits.) Change-Id: I951534f6bbeb547ce0492d5647aaf76be42108a3 Reviewed-on: https://boringssl-review.googlesource.com/8179 Reviewed-by: Steven Valdez Reviewed-by: David Benjamin --- ssl/s3_both.c | 26 +++++++++----------------- ssl/s3_lib.c | 1 - 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/ssl/s3_both.c b/ssl/s3_both.c index 3c1e619c..e16bf4b3 100644 --- a/ssl/s3_both.c +++ b/ssl/s3_both.c @@ -130,27 +130,20 @@ /* ssl3_do_write sends |ssl->init_buf| in records of type 'type' - * (SSL3_RT_HANDSHAKE or SSL3_RT_CHANGE_CIPHER_SPEC). It returns -1 on error, 1 - * on success or zero if the transmission is still incomplete. */ + * (SSL3_RT_HANDSHAKE or SSL3_RT_CHANGE_CIPHER_SPEC). It returns -1 on error and + * 1 on success. */ int ssl3_do_write(SSL *ssl, int type) { - int n; - - n = ssl3_write_bytes(ssl, type, &ssl->init_buf->data[ssl->init_off], - ssl->init_num); + int n = ssl3_write_bytes(ssl, type, ssl->init_buf->data, ssl->init_num); if (n < 0) { return -1; } - if (n == ssl->init_num) { - ssl_do_msg_callback(ssl, 1 /* write */, ssl->version, type, - ssl->init_buf->data, - (size_t)(ssl->init_off + ssl->init_num)); - return 1; - } - - ssl->init_off += n; - ssl->init_num -= n; - return 0; + /* ssl3_write_bytes writes the data in its entirety. */ + assert(n == ssl->init_num); + ssl_do_msg_callback(ssl, 1 /* write */, ssl->version, type, + ssl->init_buf->data, (size_t)ssl->init_num); + ssl->init_num = 0; + return 1; } int ssl3_send_finished(SSL *ssl, int a, int b) { @@ -272,7 +265,6 @@ int ssl3_send_change_cipher_spec(SSL *ssl, int a, int b) { if (ssl->state == a) { *((uint8_t *)ssl->init_buf->data) = SSL3_MT_CCS; ssl->init_num = 1; - ssl->init_off = 0; ssl->state = b; } diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 4cf5aa3c..a86478b1 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -171,7 +171,6 @@ int ssl3_set_handshake_header(SSL *ssl, int htype, unsigned long len) { *(p++) = htype; l2n3(len, p); ssl->init_num = (int)len + SSL3_HM_HEADER_LENGTH; - ssl->init_off = 0; /* Add the message to the handshake hash. */ return ssl3_update_handshake_hash(ssl, (uint8_t *)ssl->init_buf->data,