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 <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
This commit is contained in:
David Benjamin 2016-06-07 15:06:39 -04:00
parent af62d61df3
commit 2a08c8d85d
2 changed files with 9 additions and 18 deletions

View File

@ -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;
}

View File

@ -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,