diff options
author | Matt Caswell <matt@openssl.org> | 2015-02-02 11:53:20 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-03-26 15:01:59 +0000 |
commit | af9752e5faff5dd3c82fc2d02d1e7ad457ccb84a (patch) | |
tree | e66dcef06c66f23bd563438c101d35d4a3124dbc /ssl | |
parent | a0682a5e26dc7ac1466b218cc87d322094651518 (diff) | |
download | openssl-new-af9752e5faff5dd3c82fc2d02d1e7ad457ccb84a.tar.gz |
Create RECORD_LAYER_clear function.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/record/rec_layer.h | 1 | ||||
-rw-r--r-- | ssl/record/s3_pkt.c | 27 | ||||
-rw-r--r-- | ssl/ssl_lib.c | 22 |
3 files changed, 29 insertions, 21 deletions
diff --git a/ssl/record/rec_layer.h b/ssl/record/rec_layer.h index 1f6fea15a2..648fd3cdd5 100644 --- a/ssl/record/rec_layer.h +++ b/ssl/record/rec_layer.h @@ -166,6 +166,7 @@ typedef struct record_layer_st { #define RECORD_LAYER_get_rrec(rl) (&(rl)->rrec) #define RECORD_LAYER_get_wrec(rl) (&(rl)->wrec) +void RECORD_LAYER_clear(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 b9d0575301..ec3f0a1fe8 100644 --- a/ssl/record/s3_pkt.c +++ b/ssl/record/s3_pkt.c @@ -132,6 +132,33 @@ # define EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0 #endif +void RECORD_LAYER_clear(RECORD_LAYER *rl) +{ + unsigned char *rp, *wp; + size_t rlen, wlen; + int read_ahead; + SSL *s; + + s = rl->s; + read_ahead = rl->read_ahead; + rp = SSL3_BUFFER_get_buf(&rl->rbuf); + rlen = SSL3_BUFFER_get_len(&rl->rbuf); + wp = SSL3_BUFFER_get_buf(&rl->wbuf); + wlen = SSL3_BUFFER_get_len(&rl->wbuf); + memset(rl, 0, sizeof (RECORD_LAYER)); + SSL3_BUFFER_set_buf(&rl->rbuf, rp); + SSL3_BUFFER_set_len(&rl->rbuf, rlen); + SSL3_BUFFER_set_buf(&rl->wbuf, wp); + SSL3_BUFFER_set_len(&rl->wbuf, wlen); + + /* Do I need to do this? As far as I can tell read_ahead did not + * previously get reset by SSL_clear...so I'll keep it that way..but is + * that right? + */ + rl->read_ahead = read_ahead; + rl->s = s; +} + int ssl3_read_n(SSL *s, int n, int max, int extend) { /* diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 727f91305f..0298501ada 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -189,10 +189,6 @@ SSL3_ENC_METHOD ssl3_undef_enc_method = { int SSL_clear(SSL *s) { - unsigned char *rp, *wp; - size_t rlen, wlen; - int read_ahead; - if (s->method == NULL) { SSLerr(SSL_F_SSL_CLEAR, SSL_R_NO_METHOD_SPECIFIED); return (0); @@ -245,23 +241,7 @@ int SSL_clear(SSL *s) } else s->method->ssl_clear(s); - read_ahead = RECORD_LAYER_get_read_ahead(&s->rlayer); - rp = SSL3_BUFFER_get_buf(RECORD_LAYER_get_rbuf(&s->rlayer)); - rlen = SSL3_BUFFER_get_len(RECORD_LAYER_get_rbuf(&s->rlayer)); - wp = SSL3_BUFFER_get_buf(RECORD_LAYER_get_wbuf(&s->rlayer)); - wlen = SSL3_BUFFER_get_len(RECORD_LAYER_get_wbuf(&s->rlayer)); - memset(&s->rlayer, 0, sizeof s->rlayer); - SSL3_BUFFER_set_buf(RECORD_LAYER_get_rbuf(&s->rlayer), rp); - SSL3_BUFFER_set_len(RECORD_LAYER_get_rbuf(&s->rlayer), rlen); - SSL3_BUFFER_set_buf(RECORD_LAYER_get_wbuf(&s->rlayer), wp); - SSL3_BUFFER_set_len(RECORD_LAYER_get_wbuf(&s->rlayer), wlen); - - /* Do I need to do this? As far as I can tell read_ahead did not - * previously get reset by SSL_clear...so I'll keep it that way..but is - * that right? - */ - RECORD_LAYER_set_read_ahead(&s->rlayer, read_ahead); - RECORD_LAYER_set_ssl(&s->rlayer, s); + RECORD_LAYER_clear(&s->rlayer); return (1); } |