Move s->s3->rrec into s->rlayer
Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
parent
28d59af874
commit
33d23b87a0
@ -109,6 +109,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../ssl_locl.h"
|
||||
|
||||
typedef struct record_layer_st {
|
||||
/* The parent SSL structure */
|
||||
SSL *s;
|
||||
@ -117,9 +119,11 @@ typedef struct record_layer_st {
|
||||
* non-blocking reads)
|
||||
*/
|
||||
int read_ahead;
|
||||
/* read IO goes into here */
|
||||
SSL3_BUFFER rbuf;
|
||||
} RECORD_LAYER;
|
||||
|
||||
#define RECORD_LAYER_set_ssl(rl, s) ((rl)->s = (s))
|
||||
#define RECORD_LAYER_set_read_ahead(rl, ra) ((rl)->read_ahead = (ra))
|
||||
#define RECORD_LAYER_get_read_ahead(rl) ((rl)->read_ahead)
|
||||
#define RECORD_LAYER_get_rbuf(rl) (&(rl)->s->s3->rbuf)
|
||||
#define RECORD_LAYER_get_rbuf(rl) (&(rl)->rbuf)
|
||||
|
10
ssl/s3_lib.c
10
ssl/s3_lib.c
@ -3131,8 +3131,6 @@ void ssl3_free(SSL *s)
|
||||
return;
|
||||
|
||||
ssl3_cleanup_key_block(s);
|
||||
if (SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer)))
|
||||
ssl3_release_read_buffer(s);
|
||||
if (s->s3->wbuf.buf != NULL)
|
||||
ssl3_release_write_buffer(s);
|
||||
if (s->s3->rrec.comp != NULL)
|
||||
@ -3164,8 +3162,8 @@ void ssl3_free(SSL *s)
|
||||
|
||||
void ssl3_clear(SSL *s)
|
||||
{
|
||||
unsigned char *rp, *wp;
|
||||
size_t rlen, wlen;
|
||||
unsigned char *wp;
|
||||
size_t wlen;
|
||||
int init_extra;
|
||||
|
||||
ssl3_cleanup_key_block(s);
|
||||
@ -3190,9 +3188,7 @@ void ssl3_clear(SSL *s)
|
||||
# endif /* !OPENSSL_NO_EC */
|
||||
#endif /* !OPENSSL_NO_TLSEXT */
|
||||
|
||||
rp = SSL3_BUFFER_get_buf(RECORD_LAYER_get_rbuf(&s->rlayer));
|
||||
wp = s->s3->wbuf.buf;
|
||||
rlen = SSL3_BUFFER_get_len(RECORD_LAYER_get_rbuf(&s->rlayer));
|
||||
wlen = s->s3->wbuf.len;
|
||||
init_extra = s->s3->init_extra;
|
||||
BIO_free(s->s3->handshake_buffer);
|
||||
@ -3207,9 +3203,7 @@ void ssl3_clear(SSL *s)
|
||||
}
|
||||
#endif
|
||||
memset(s->s3, 0, sizeof *s->s3);
|
||||
SSL3_BUFFER_set_buf(RECORD_LAYER_get_rbuf(&s->rlayer), rp);
|
||||
s->s3->wbuf.buf = wp;
|
||||
SSL3_BUFFER_set_len(RECORD_LAYER_get_rbuf(&s->rlayer), rlen);
|
||||
s->s3->wbuf.len = wlen;
|
||||
s->s3->init_extra = init_extra;
|
||||
|
||||
|
@ -189,6 +189,9 @@ SSL3_ENC_METHOD ssl3_undef_enc_method = {
|
||||
|
||||
int SSL_clear(SSL *s)
|
||||
{
|
||||
unsigned char *rp;
|
||||
size_t rlen;
|
||||
int read_ahead;
|
||||
|
||||
if (s->method == NULL) {
|
||||
SSLerr(SSL_F_SSL_CLEAR, SSL_R_NO_METHOD_SPECIFIED);
|
||||
@ -241,6 +244,20 @@ int SSL_clear(SSL *s)
|
||||
return (0);
|
||||
} 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));
|
||||
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);
|
||||
|
||||
/* 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);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
@ -599,6 +616,9 @@ 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 (s->ctx)
|
||||
SSL_CTX_free(s->ctx);
|
||||
|
||||
|
@ -165,8 +165,8 @@
|
||||
# include <openssl/ssl.h>
|
||||
# include <openssl/symhacks.h>
|
||||
|
||||
#include "record/rec_layer.h"
|
||||
#include "record/ssl3_buffer.h"
|
||||
#include "record/rec_layer.h"
|
||||
|
||||
# ifdef OPENSSL_BUILD_SHLIBSSL
|
||||
# undef OPENSSL_EXTERN
|
||||
@ -1281,7 +1281,6 @@ typedef struct ssl3_state_st {
|
||||
int empty_fragment_done;
|
||||
/* The value of 'extra' when the buffers were initialized */
|
||||
int init_extra;
|
||||
SSL3_BUFFER rbuf; /* read IO goes into here */
|
||||
SSL3_BUFFER wbuf; /* write IO goes into here */
|
||||
SSL3_RECORD rrec; /* each decoded record goes in here */
|
||||
SSL3_RECORD wrec; /* goes out from here */
|
||||
|
Loading…
Reference in New Issue
Block a user