summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2021-12-22 09:12:25 +0100
committerDaiki Ueno <ueno@gnu.org>2021-12-22 09:12:25 +0100
commit3db352734472d851318944db13be73da61300568 (patch)
tree99fbb2d84e466266b581544665a2fca5bc9b3a21 /lib
parent1e9580fa3d0bc21939a5d726604fadd782ed280d (diff)
downloadgnutls-3db352734472d851318944db13be73da61300568.tar.gz
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/nettle/mac.c4
1 files changed, 3 insertions, 1 deletions
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;