Fix ssl3_do_write error handling.

The functions it calls all pass through <= 0 as error codes, not < 0.

Change-Id: I9d0d6b1df0065efc63f2d3a5e7f3497b2c28453a
Reviewed-on: https://boringssl-review.googlesource.com/8237
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2016-06-09 19:01:11 -04:00 committed by Adam Langley
parent 1669589445
commit 171b5403ee

View File

@ -130,16 +130,16 @@
/* ssl3_do_write sends |ssl->init_buf| in records of type 'type' /* 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 and * (SSL3_RT_HANDSHAKE or SSL3_RT_CHANGE_CIPHER_SPEC). It returns 1 on success
* 1 on success. */ * and <= 0 on error. */
int ssl3_do_write(SSL *ssl, int type) { int ssl3_do_write(SSL *ssl, int type) {
int n = ssl3_write_bytes(ssl, type, ssl->init_buf->data, ssl->init_num); int ret = ssl3_write_bytes(ssl, type, ssl->init_buf->data, ssl->init_num);
if (n < 0) { if (ret <= 0) {
return -1; return ret;
} }
/* ssl3_write_bytes writes the data in its entirety. */ /* ssl3_write_bytes writes the data in its entirety. */
assert(n == ssl->init_num); assert(ret == ssl->init_num);
ssl_do_msg_callback(ssl, 1 /* write */, ssl->version, type, ssl_do_msg_callback(ssl, 1 /* write */, ssl->version, type,
ssl->init_buf->data, (size_t)ssl->init_num); ssl->init_buf->data, (size_t)ssl->init_num);
ssl->init_num = 0; ssl->init_num = 0;