summaryrefslogtreecommitdiffstats
path: root/ssl/record/rec_layer_d1.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2015-05-01 23:10:31 -0400
committerRich Salz <rsalz@openssl.org>2015-05-04 15:00:13 -0400
commitb4faea50c35d92a67d1369355b49cc3efba78406 (patch)
treecfebea69d625f936c9fd7281f1fa3eaa2fa38834 /ssl/record/rec_layer_d1.c
parent8920a7cd04f43b1a090d0b0a8c9e16b94c6898d4 (diff)
Use safer sizeof variant in malloc
For a local variable: TYPE *p; Allocations like this are "risky": p = OPENSSL_malloc(sizeof(TYPE)); if the type of p changes, and the malloc call isn't updated, you could get memory corruption. Instead do this: p = OPENSSL_malloc(sizeof(*p)); Also fixed a few memset() calls that I noticed while doing this. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'ssl/record/rec_layer_d1.c')
-rw-r--r--ssl/record/rec_layer_d1.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/ssl/record/rec_layer_d1.c b/ssl/record/rec_layer_d1.c
index a484c97bb5..2635894ed3 100644
--- a/ssl/record/rec_layer_d1.c
+++ b/ssl/record/rec_layer_d1.c
@@ -127,9 +127,8 @@ int DTLS_RECORD_LAYER_new(RECORD_LAYER *rl)
{
DTLS_RECORD_LAYER *d;
- if ((d = OPENSSL_malloc(sizeof *d)) == NULL) {
+ if ((d = OPENSSL_malloc(sizeof(*d))) == NULL)
return (0);
- }
rl->d = d;
@@ -196,7 +195,7 @@ void DTLS_RECORD_LAYER_clear(RECORD_LAYER *rl)
unprocessed_rcds = d->unprocessed_rcds.q;
processed_rcds = d->processed_rcds.q;
buffered_app_data = d->buffered_app_data.q;
- memset(d, 0, sizeof *d);
+ memset(d, 0, sizeof(*d));
d->unprocessed_rcds.q = unprocessed_rcds;
d->processed_rcds.q = processed_rcds;
d->buffered_app_data.q = buffered_app_data;
@@ -259,7 +258,7 @@ int dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority)
if (pqueue_size(queue->q) >= 100)
return 0;
- rdata = OPENSSL_malloc(sizeof(DTLS1_RECORD_DATA));
+ rdata = OPENSSL_malloc(sizeof(*rdata));
item = pitem_new(priority, rdata);
if (rdata == NULL || item == NULL) {
OPENSSL_free(rdata);