From a857159dd61204bfe93bd8e2f00448434e8b0b99 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Thu, 10 Mar 2016 01:41:55 -0500 Subject: [PATCH] Clean up some silly variable names. Change-Id: I5b38e2938811520f52ece6055245248c80308b4d Reviewed-on: https://boringssl-review.googlesource.com/7416 Reviewed-by: Steven Valdez Reviewed-by: David Benjamin --- ssl/d1_pkt.c | 55 +++++++++++++++++-------------------- ssl/s3_pkt.c | 75 +++++++++++++++++++++++++-------------------------- ssl/s3_srvr.c | 5 ++-- 3 files changed, 62 insertions(+), 73 deletions(-) diff --git a/ssl/d1_pkt.c b/ssl/d1_pkt.c index 7b7b2b0f..856b847f 100644 --- a/ssl/d1_pkt.c +++ b/ssl/d1_pkt.c @@ -539,42 +539,35 @@ static int do_dtls1_write(SSL *ssl, int type, const uint8_t *buf, } int dtls1_dispatch_alert(SSL *ssl) { - int i, j; - void (*cb)(const SSL *ssl, int type, int value) = NULL; - uint8_t buf[DTLS1_AL_HEADER_LENGTH]; - uint8_t *ptr = &buf[0]; - ssl->s3->alert_dispatch = 0; - - memset(buf, 0x00, sizeof(buf)); - *ptr++ = ssl->s3->send_alert[0]; - *ptr++ = ssl->s3->send_alert[1]; - - i = do_dtls1_write(ssl, SSL3_RT_ALERT, &buf[0], sizeof(buf), - dtls1_use_current_epoch); - if (i <= 0) { + int ret = do_dtls1_write(ssl, SSL3_RT_ALERT, &ssl->s3->send_alert[0], 2, + dtls1_use_current_epoch); + if (ret <= 0) { ssl->s3->alert_dispatch = 1; - } else { - if (ssl->s3->send_alert[0] == SSL3_AL_FATAL) { - (void)BIO_flush(ssl->wbio); - } + return ret; + } - if (ssl->msg_callback) { - ssl->msg_callback(1, ssl->version, SSL3_RT_ALERT, ssl->s3->send_alert, 2, - ssl, ssl->msg_callback_arg); - } + /* If the alert is fatal, flush the BIO now. */ + if (ssl->s3->send_alert[0] == SSL3_AL_FATAL) { + BIO_flush(ssl->wbio); + } - if (ssl->info_callback != NULL) { - cb = ssl->info_callback; - } else if (ssl->ctx->info_callback != NULL) { - cb = ssl->ctx->info_callback; - } + if (ssl->msg_callback != NULL) { + ssl->msg_callback(1 /* write */, ssl->version, SSL3_RT_ALERT, + ssl->s3->send_alert, 2, ssl, ssl->msg_callback_arg); + } - if (cb != NULL) { - j = (ssl->s3->send_alert[0] << 8) | ssl->s3->send_alert[1]; - cb(ssl, SSL_CB_WRITE_ALERT, j); - } + void (*cb)(const SSL *ssl, int type, int value) = NULL; + if (ssl->info_callback != NULL) { + cb = ssl->info_callback; + } else if (ssl->ctx->info_callback != NULL) { + cb = ssl->ctx->info_callback; } - return i; + if (cb != NULL) { + int alert = (ssl->s3->send_alert[0] << 8) | ssl->s3->send_alert[1]; + cb(ssl, SSL_CB_WRITE_ALERT, alert); + } + + return 1; } diff --git a/ssl/s3_pkt.c b/ssl/s3_pkt.c index 81d163e8..4b6d98f1 100644 --- a/ssl/s3_pkt.c +++ b/ssl/s3_pkt.c @@ -190,8 +190,7 @@ int ssl3_write_app_data(SSL *ssl, const void *buf, int len) { * not all data has been sent or non-blocking IO. */ int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, int len) { const uint8_t *buf = buf_; - unsigned int tot, n, nw; - int i; + unsigned tot, n, nw; ssl->rwstate = SSL_NOTHING; assert(ssl->s3->wnum <= INT_MAX); @@ -199,11 +198,11 @@ int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, int len) { ssl->s3->wnum = 0; if (!ssl->in_handshake && SSL_in_init(ssl) && !SSL_in_false_start(ssl)) { - i = ssl->handshake_func(ssl); - if (i < 0) { - return i; + int ret = ssl->handshake_func(ssl); + if (ret < 0) { + return ret; } - if (i == 0) { + if (ret == 0) { OPENSSL_PUT_ERROR(SSL, SSL_R_SSL_HANDSHAKE_FAILURE); return -1; } @@ -232,19 +231,19 @@ int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, int len) { nw = n; } - i = do_ssl3_write(ssl, type, &buf[tot], nw); - if (i <= 0) { + int ret = do_ssl3_write(ssl, type, &buf[tot], nw); + if (ret <= 0) { ssl->s3->wnum = tot; - return i; + return ret; } - if (i == (int)n || (type == SSL3_RT_APPLICATION_DATA && - (ssl->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) { - return tot + i; + if (ret == (int)n || (type == SSL3_RT_APPLICATION_DATA && + (ssl->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) { + return tot + ret; } - n -= i; - tot += i; + n -= ret; + tot += ret; } } @@ -658,36 +657,34 @@ int ssl3_send_alert(SSL *ssl, int level, int desc) { } int ssl3_dispatch_alert(SSL *ssl) { - int i, j; - void (*cb)(const SSL *ssl, int type, int value) = NULL; - ssl->s3->alert_dispatch = 0; - i = do_ssl3_write(ssl, SSL3_RT_ALERT, &ssl->s3->send_alert[0], 2); - if (i <= 0) { + int ret = do_ssl3_write(ssl, SSL3_RT_ALERT, &ssl->s3->send_alert[0], 2); + if (ret <= 0) { ssl->s3->alert_dispatch = 1; - } else { - /* Alert sent to BIO. If it is important, flush it now. If the message - * does not get sent due to non-blocking IO, we will not worry too much. */ - if (ssl->s3->send_alert[0] == SSL3_AL_FATAL) { - BIO_flush(ssl->wbio); - } + return ret; + } - if (ssl->msg_callback) { - ssl->msg_callback(1, ssl->version, SSL3_RT_ALERT, ssl->s3->send_alert, 2, - ssl, ssl->msg_callback_arg); - } + /* If the alert is fatal, flush the BIO now. */ + if (ssl->s3->send_alert[0] == SSL3_AL_FATAL) { + BIO_flush(ssl->wbio); + } - if (ssl->info_callback != NULL) { - cb = ssl->info_callback; - } else if (ssl->ctx->info_callback != NULL) { - cb = ssl->ctx->info_callback; - } + if (ssl->msg_callback != NULL) { + ssl->msg_callback(1 /* write */, ssl->version, SSL3_RT_ALERT, + ssl->s3->send_alert, 2, ssl, ssl->msg_callback_arg); + } - if (cb != NULL) { - j = (ssl->s3->send_alert[0] << 8) | ssl->s3->send_alert[1]; - cb(ssl, SSL_CB_WRITE_ALERT, j); - } + void (*cb)(const SSL *ssl, int type, int value) = NULL; + if (ssl->info_callback != NULL) { + cb = ssl->info_callback; + } else if (ssl->ctx->info_callback != NULL) { + cb = ssl->ctx->info_callback; } - return i; + if (cb != NULL) { + int alert = (ssl->s3->send_alert[0] << 8) | ssl->s3->send_alert[1]; + cb(ssl, SSL_CB_WRITE_ALERT, alert); + } + + return 1; } diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index 1f2d0765..fe61de5e 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -1831,7 +1831,7 @@ err: } int ssl3_get_client_certificate(SSL *ssl) { - int i, ok, al, ret = -1; + int ok, al, ret = -1; X509 *x = NULL; unsigned long n; STACK_OF(X509) *sk = NULL; @@ -1945,8 +1945,7 @@ int ssl3_get_client_certificate(SSL *ssl) { goto f_err; } } else { - i = ssl_verify_cert_chain(ssl, sk); - if (i <= 0) { + if (ssl_verify_cert_chain(ssl, sk) <= 0) { al = ssl_verify_alarm_type(ssl->verify_result); OPENSSL_PUT_ERROR(SSL, SSL_R_CERTIFICATE_VERIFY_FAILED); goto f_err;