]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
wrap_nettle_hash_fast: avoid calling _update with zero-length input
authorDaiki Ueno <ueno@gnu.org>
Wed, 22 Dec 2021 08:12:25 +0000 (09:12 +0100)
committerDaiki Ueno <ueno@gnu.org>
Wed, 22 Dec 2021 08:12:25 +0000 (09:12 +0100)
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>
lib/nettle/mac.c

index f9d4d7a8df1289a10e7dc849969f1ba249879f90..35e070fab04ec08332dbd4272cdec2a0cb43c5ea 100644 (file)
@@ -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;