summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-12-06 10:49:01 +0000
committerMatt Caswell <matt@openssl.org>2016-12-12 13:12:25 +0000
commit4bf086005fe5ebcda5dc4d48ff701b41ab9b07f0 (patch)
tree5f4385dac976af613846f95f4dff3cf76c711d73 /ssl
parent82e089308bd9a7794a45f0fa3973d7659420fbd8 (diff)
Fix a leak in SSL_clear()
SSL_clear() was resetting numwpipes to 0, but not freeing any allocated memory for existing write buffers. Fixes #2026 Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'ssl')
-rw-r--r--ssl/record/rec_layer_s3.c6
-rw-r--r--ssl/record/ssl3_buffer.c12
2 files changed, 9 insertions, 9 deletions
diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c
index 62bc3b08e4..93b7d05b8d 100644
--- a/ssl/record/rec_layer_s3.c
+++ b/ssl/record/rec_layer_s3.c
@@ -39,8 +39,6 @@ void RECORD_LAYER_init(RECORD_LAYER *rl, SSL *s)
void RECORD_LAYER_clear(RECORD_LAYER *rl)
{
- unsigned int pipes;
-
rl->rstate = SSL_ST_READ_HEADER;
/*
@@ -62,9 +60,7 @@ void RECORD_LAYER_clear(RECORD_LAYER *rl)
rl->wpend_buf = NULL;
SSL3_BUFFER_clear(&rl->rbuf);
- for (pipes = 0; pipes < rl->numwpipes; pipes++)
- SSL3_BUFFER_clear(&rl->wbuf[pipes]);
- rl->numwpipes = 0;
+ ssl3_release_write_buffer(rl->s);
rl->numrpipes = 0;
SSL3_RECORD_clear(rl->rrec, SSL_MAX_PIPELINES);
diff --git a/ssl/record/ssl3_buffer.c b/ssl/record/ssl3_buffer.c
index df1f90092c..8a6a922261 100644
--- a/ssl/record/ssl3_buffer.c
+++ b/ssl/record/ssl3_buffer.c
@@ -105,13 +105,17 @@ int ssl3_setup_write_buffer(SSL *s, size_t numwpipes, size_t len)
wb = RECORD_LAYER_get_wbuf(&s->rlayer);
for (currpipe = 0; currpipe < numwpipes; currpipe++) {
- if (wb[currpipe].buf == NULL) {
- if ((p = OPENSSL_malloc(len)) == NULL) {
+ SSL3_BUFFER *thiswb = &wb[currpipe];
+
+ if (thiswb->buf == NULL) {
+ p = OPENSSL_malloc(len);
+ if (p == NULL) {
s->rlayer.numwpipes = currpipe;
goto err;
}
- wb[currpipe].buf = p;
- wb[currpipe].len = len;
+ memset(thiswb, 0, sizeof(SSL3_BUFFER));
+ thiswb->buf = p;
+ thiswb->len = len;
}
}