summaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/gnutls/gnutls/CVE-2021-4209.patch
blob: 0bcb55e573e6506e1f639677acd7e959a4a3156e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From 3db352734472d851318944db13be73da61300568 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@gnu.org>
Date: Wed, 22 Dec 2021 09:12:25 +0100
Subject: [PATCH] wrap_nettle_hash_fast: avoid calling _update with zero-length
 input

As Nettle's hash update functions internally call memcpy, providing
zero-length input may cause undefined behavior.

Signed-off-by: Daiki Ueno <ueno@gnu.org>

https://gitlab.com/gnutls/gnutls/-/commit/3db352734472d851318944db13be73da61300568
Upstream-Status: Backport
CVE: CVE-2021-4209
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
---
 lib/nettle/mac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/nettle/mac.c b/lib/nettle/mac.c
index f9d4d7a8df..35e070fab0 100644
--- a/lib/nettle/mac.c
+++ b/lib/nettle/mac.c
@@ -788,7 +788,9 @@ static int wrap_nettle_hash_fast(gnutls_digest_algorithm_t algo,
 	if (ret < 0)
 		return gnutls_assert_val(ret);
 
-	ctx.update(&ctx, text_size, text);
+	if (text_size > 0) {
+		ctx.update(&ctx, text_size, text);
+	}
 	ctx.digest(&ctx, ctx.length, digest);
 
 	return 0;
-- 
GitLab