提交 ab97b2cd 编写于 作者: M Matt Caswell

Move s->s3->wbuf to s->rlayer->wbuf

Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 db9a32e7
...@@ -121,10 +121,12 @@ typedef struct record_layer_st { ...@@ -121,10 +121,12 @@ typedef struct record_layer_st {
int read_ahead; int read_ahead;
/* read IO goes into here */ /* read IO goes into here */
SSL3_BUFFER rbuf; SSL3_BUFFER rbuf;
/* write IO goes into here */
SSL3_BUFFER wbuf;
} RECORD_LAYER; } RECORD_LAYER;
#define RECORD_LAYER_set_ssl(rl, s) ((rl)->s = (s)) #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_set_read_ahead(rl, ra) ((rl)->read_ahead = (ra))
#define RECORD_LAYER_get_read_ahead(rl) ((rl)->read_ahead) #define RECORD_LAYER_get_read_ahead(rl) ((rl)->read_ahead)
#define RECORD_LAYER_get_rbuf(rl) (&(rl)->rbuf) #define RECORD_LAYER_get_rbuf(rl) (&(rl)->rbuf)
#define RECORD_LAYER_get_wbuf(rl) (&(rl)->s->s3->wbuf) #define RECORD_LAYER_get_wbuf(rl) (&(rl)->wbuf)
...@@ -3131,8 +3131,6 @@ void ssl3_free(SSL *s) ...@@ -3131,8 +3131,6 @@ void ssl3_free(SSL *s)
return; return;
ssl3_cleanup_key_block(s); ssl3_cleanup_key_block(s);
if (SSL3_BUFFER_is_initialised(RECORD_LAYER_get_wbuf(&s->rlayer)))
ssl3_release_write_buffer(s);
if (s->s3->rrec.comp != NULL) if (s->s3->rrec.comp != NULL)
OPENSSL_free(s->s3->rrec.comp); OPENSSL_free(s->s3->rrec.comp);
#ifndef OPENSSL_NO_DH #ifndef OPENSSL_NO_DH
...@@ -3162,8 +3160,6 @@ void ssl3_free(SSL *s) ...@@ -3162,8 +3160,6 @@ void ssl3_free(SSL *s)
void ssl3_clear(SSL *s) void ssl3_clear(SSL *s)
{ {
unsigned char *wp;
size_t wlen;
int init_extra; int init_extra;
ssl3_cleanup_key_block(s); ssl3_cleanup_key_block(s);
...@@ -3188,8 +3184,6 @@ void ssl3_clear(SSL *s) ...@@ -3188,8 +3184,6 @@ void ssl3_clear(SSL *s)
# endif /* !OPENSSL_NO_EC */ # endif /* !OPENSSL_NO_EC */
#endif /* !OPENSSL_NO_TLSEXT */ #endif /* !OPENSSL_NO_TLSEXT */
wp = SSL3_BUFFER_get_buf(RECORD_LAYER_get_wbuf(&s->rlayer));
wlen = SSL3_BUFFER_get_len(RECORD_LAYER_get_wbuf(&s->rlayer));
init_extra = s->s3->init_extra; init_extra = s->s3->init_extra;
BIO_free(s->s3->handshake_buffer); BIO_free(s->s3->handshake_buffer);
s->s3->handshake_buffer = NULL; s->s3->handshake_buffer = NULL;
...@@ -3203,8 +3197,6 @@ void ssl3_clear(SSL *s) ...@@ -3203,8 +3197,6 @@ void ssl3_clear(SSL *s)
} }
#endif #endif
memset(s->s3, 0, sizeof *s->s3); memset(s->s3, 0, sizeof *s->s3);
SSL3_BUFFER_set_buf(RECORD_LAYER_get_wbuf(&s->rlayer), wp);
SSL3_BUFFER_set_len(RECORD_LAYER_get_wbuf(&s->rlayer), wlen);
s->s3->init_extra = init_extra; s->s3->init_extra = init_extra;
ssl_free_wbio_buffer(s); ssl_free_wbio_buffer(s);
......
...@@ -189,8 +189,8 @@ SSL3_ENC_METHOD ssl3_undef_enc_method = { ...@@ -189,8 +189,8 @@ SSL3_ENC_METHOD ssl3_undef_enc_method = {
int SSL_clear(SSL *s) int SSL_clear(SSL *s)
{ {
unsigned char *rp; unsigned char *rp, *wp;
size_t rlen; size_t rlen, wlen;
int read_ahead; int read_ahead;
if (s->method == NULL) { if (s->method == NULL) {
...@@ -248,9 +248,13 @@ int SSL_clear(SSL *s) ...@@ -248,9 +248,13 @@ int SSL_clear(SSL *s)
read_ahead = RECORD_LAYER_get_read_ahead(&s->rlayer); read_ahead = RECORD_LAYER_get_read_ahead(&s->rlayer);
rp = SSL3_BUFFER_get_buf(RECORD_LAYER_get_rbuf(&s->rlayer)); rp = SSL3_BUFFER_get_buf(RECORD_LAYER_get_rbuf(&s->rlayer));
rlen = SSL3_BUFFER_get_len(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); memset(&s->rlayer, 0, sizeof s->rlayer);
SSL3_BUFFER_set_buf(RECORD_LAYER_get_rbuf(&s->rlayer), rp); 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_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 /* 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 * previously get reset by SSL_clear...so I'll keep it that way..but is
...@@ -619,6 +623,8 @@ void SSL_free(SSL *s) ...@@ -619,6 +623,8 @@ void SSL_free(SSL *s)
if (SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer))) if (SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer)))
ssl3_release_read_buffer(s); ssl3_release_read_buffer(s);
if (SSL3_BUFFER_is_initialised(RECORD_LAYER_get_wbuf(&s->rlayer)))
ssl3_release_write_buffer(s);
if (s->ctx) if (s->ctx)
SSL_CTX_free(s->ctx); SSL_CTX_free(s->ctx);
......
...@@ -1281,7 +1281,6 @@ typedef struct ssl3_state_st { ...@@ -1281,7 +1281,6 @@ typedef struct ssl3_state_st {
int empty_fragment_done; int empty_fragment_done;
/* The value of 'extra' when the buffers were initialized */ /* The value of 'extra' when the buffers were initialized */
int init_extra; int init_extra;
SSL3_BUFFER wbuf; /* write IO goes into here */
SSL3_RECORD rrec; /* each decoded record goes in here */ SSL3_RECORD rrec; /* each decoded record goes in here */
SSL3_RECORD wrec; /* goes out from here */ SSL3_RECORD wrec; /* goes out from here */
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册