All of lore.kernel.org
 help / color / mirror / Atom feed
From: Will Dietz <w@wdtz.org>
To: ell@lists.01.org
Subject: [PATCH] ell/tls: fix crash, don't index through adj. stack objs
Date: Mon, 28 Oct 2019 14:41:12 -0500	[thread overview]
Message-ID: <20191028194112.11921-1-w@wdtz.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1179 bytes --]

Building with clang may make this more likely to crash,
problem is encountered on ell/tls.c:114 (before).

Also, use memmove as src/dst may overlap.
---
 ell/tls.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ell/tls.c b/ell/tls.c
index 0e06c27..50df446 100644
--- a/ell/tls.c
+++ b/ell/tls.c
@@ -92,7 +92,8 @@ bool tls12_prf(enum l_checksum_type type,
 {
 	struct l_checksum *hmac = l_checksum_new_hmac(type, secret, secret_len);
 	size_t a_len, chunk_len, prfseed_len = strlen(label) + seed_len;
-	uint8_t a[128], prfseed[prfseed_len];
+	uint8_t a[128 + prfseed_len];
+	uint8_t *prfseed = &a[128];
 
 	if (!hmac)
 		return false;
@@ -108,10 +109,10 @@ bool tls12_prf(enum l_checksum_type type,
 		/* Generate A(i) */
 		l_checksum_reset(hmac);
 		l_checksum_update(hmac, a, a_len);
-		a_len = l_checksum_get_digest(hmac, a, sizeof(a));
+		a_len = l_checksum_get_digest(hmac, a, 128);
 
 		/* Append seed & generate output */
-		memcpy(a + a_len, prfseed, prfseed_len);
+		memmove(a + a_len, prfseed, prfseed_len);
 		l_checksum_reset(hmac);
 		l_checksum_update(hmac, a, a_len + prfseed_len);
 
-- 
2.24.0-rc1

                 reply	other threads:[~2019-10-28 19:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191028194112.11921-1-w@wdtz.org \
    --to=w@wdtz.org \
    --cc=ell@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.