diff options
author | Matt Caswell <matt@openssl.org> | 2015-02-02 12:18:03 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-03-26 15:01:59 +0000 |
commit | f161995e0e1a77415354b1690fb92ae3f1480547 (patch) | |
tree | 8a5742e61846de6a150b3c6937ebe8253ff1442b | |
parent | af9752e5faff5dd3c82fc2d02d1e7ad457ccb84a (diff) |
Introduce the functions RECORD_LAYER_release, RECORD_LAYER_read_pending, and
RECORD_LAYER_write_pending.
Reviewed-by: Richard Levitte <levitte@openssl.org>
-rw-r--r-- | ssl/record/rec_layer.h | 3 | ||||
-rw-r--r-- | ssl/record/s3_pkt.c | 19 | ||||
-rw-r--r-- | ssl/s3_lib.c | 4 | ||||
-rw-r--r-- | ssl/s3_msg.c | 2 | ||||
-rw-r--r-- | ssl/ssl_lib.c | 6 |
5 files changed, 26 insertions, 8 deletions
diff --git a/ssl/record/rec_layer.h b/ssl/record/rec_layer.h index 648fd3cdd5..96e245e2c0 100644 --- a/ssl/record/rec_layer.h +++ b/ssl/record/rec_layer.h @@ -167,6 +167,9 @@ typedef struct record_layer_st { #define RECORD_LAYER_get_wrec(rl) (&(rl)->wrec) void RECORD_LAYER_clear(RECORD_LAYER *rl); +void RECORD_LAYER_release(RECORD_LAYER *rl); +int RECORD_LAYER_read_pending(RECORD_LAYER *rl); +int RECORD_LAYER_write_pending(RECORD_LAYER *rl); __owur int ssl23_read_bytes(SSL *s, int n); __owur int ssl23_write_bytes(SSL *s); __owur int ssl3_write_bytes(SSL *s, int type, const void *buf, int len); diff --git a/ssl/record/s3_pkt.c b/ssl/record/s3_pkt.c index ec3f0a1fe8..21ded63e38 100644 --- a/ssl/record/s3_pkt.c +++ b/ssl/record/s3_pkt.c @@ -159,6 +159,25 @@ void RECORD_LAYER_clear(RECORD_LAYER *rl) rl->s = s; } +void RECORD_LAYER_release(RECORD_LAYER *rl) +{ + if (SSL3_BUFFER_is_initialised(&rl->rbuf)) + ssl3_release_read_buffer(rl->s); + if (SSL3_BUFFER_is_initialised(&rl->wbuf)) + ssl3_release_write_buffer(rl->s); + SSL3_RECORD_release(&rl->rrec); +} + +int RECORD_LAYER_read_pending(RECORD_LAYER *rl) +{ + return SSL3_BUFFER_get_left(&rl->rbuf) != 0; +} + +int RECORD_LAYER_write_pending(RECORD_LAYER *rl) +{ + return SSL3_BUFFER_get_left(&rl->wbuf) != 0; +} + int ssl3_read_n(SSL *s, int n, int max, int extend) { /* diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 6066c7807d..2b745f60a3 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -4473,8 +4473,8 @@ int ssl3_renegotiate_check(SSL *s) int ret = 0; if (s->s3->renegotiate) { - if ((SSL3_BUFFER_get_left(RECORD_LAYER_get_rbuf(&s->rlayer)) == 0) - && (SSL3_BUFFER_get_left(RECORD_LAYER_get_wbuf(&s->rlayer)) == 0) + if (!RECORD_LAYER_read_pending(&s->rlayer) + && !RECORD_LAYER_write_pending(&s->rlayer) && !SSL_in_init(s)) { /* * if we are the server, and we have sent a 'RENEGOTIATE' diff --git a/ssl/s3_msg.c b/ssl/s3_msg.c index 8fc92c1d47..fcf4744190 100644 --- a/ssl/s3_msg.c +++ b/ssl/s3_msg.c @@ -179,7 +179,7 @@ int ssl3_send_alert(SSL *s, int level, int desc) s->s3->alert_dispatch = 1; s->s3->send_alert[0] = level; s->s3->send_alert[1] = desc; - if (SSL3_BUFFER_get_left(RECORD_LAYER_get_wbuf(&s->rlayer)) == 0) { + if (!RECORD_LAYER_write_pending(&s->rlayer)) { /* data still being written out? */ return s->method->ssl_dispatch_alert(s); } diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 0298501ada..9a29d9c60a 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -603,11 +603,7 @@ void SSL_free(SSL *s) if (s->method != NULL) s->method->ssl_free(s); - if (SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer))) - ssl3_release_read_buffer(s); - if (SSL3_BUFFER_is_initialised(RECORD_LAYER_get_wbuf(&s->rlayer))) - ssl3_release_write_buffer(s); - SSL3_RECORD_release(RECORD_LAYER_get_rrec(&s->rlayer)); + RECORD_LAYER_release(&s->rlayer); if (s->ctx) SSL_CTX_free(s->ctx); |