summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2018-11-10 01:34:03 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2018-11-10 01:34:03 +0000
commit5b91ec6e061e44006192d970532f142e42acd53a (patch)
treeb28df08951a271f32ca9ff73d6840de3a65d921b
parentd1dde1796da47ba159adcd305b32f457d24428a4 (diff)
Avoid a double allocation and memory leak.
Reported by Ben L <bobsayshilol at live dot co dot uk>
-rw-r--r--lib/libssl/tls13_key_schedule.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/libssl/tls13_key_schedule.c b/lib/libssl/tls13_key_schedule.c
index 25c183fbb04..af273d6d27e 100644
--- a/lib/libssl/tls13_key_schedule.c
+++ b/lib/libssl/tls13_key_schedule.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tls13_key_schedule.c,v 1.5 2018/11/10 00:18:25 beck Exp $ */
+/* $OpenBSD: tls13_key_schedule.c,v 1.6 2018/11/10 01:34:02 jsing Exp $ */
/* Copyright (c) 2018, Bob Beck <beck@openbsd.org>
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -80,6 +80,7 @@ tls13_secrets_create(const EVP_MD *digest, int resumption)
if ((secrets = calloc(1, sizeof(struct tls13_secrets))) == NULL)
goto err;
+
if ((secrets->zeros.data = calloc(hash_length, sizeof(uint8_t))) ==
NULL)
goto err;
@@ -108,9 +109,6 @@ tls13_secrets_create(const EVP_MD *digest, int resumption)
if ((secrets->extracted_handshake.data = malloc(hash_length)) == NULL)
goto err;
secrets->extracted_handshake.len = hash_length;
- if ((secrets->extracted_handshake.data = malloc(hash_length)) == NULL)
- goto err;
- secrets->extracted_handshake.len = hash_length;
if ((secrets->client_handshake_traffic.data = malloc(hash_length))
== NULL)
goto err;