Blame SOURCES/0410-libgcrypt-mpi-Fix-possible-unintended-sign-extension.patch

80913e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
80913e
From: Darren Kenny <darren.kenny@oracle.com>
80913e
Date: Tue, 3 Nov 2020 16:43:37 +0000
80913e
Subject: [PATCH] libgcrypt/mpi: Fix possible unintended sign extension
80913e
80913e
The array of unsigned char gets promoted to a signed 32-bit int before
80913e
it is finally promoted to a size_t. There is the possibility that this
80913e
may result in the signed-bit being set for the intermediate signed
80913e
32-bit int. We should ensure that the promotion is to the correct type
80913e
before we bitwise-OR the values.
80913e
80913e
Fixes: CID 96697
80913e
80913e
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
80913e
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
80913e
---
80913e
 grub-core/lib/libgcrypt/mpi/mpicoder.c | 2 +-
80913e
 1 file changed, 1 insertion(+), 1 deletion(-)
80913e
80913e
diff --git a/grub-core/lib/libgcrypt/mpi/mpicoder.c b/grub-core/lib/libgcrypt/mpi/mpicoder.c
b32e65
index a3435ed14..7ecad27b2 100644
80913e
--- a/grub-core/lib/libgcrypt/mpi/mpicoder.c
80913e
+++ b/grub-core/lib/libgcrypt/mpi/mpicoder.c
80913e
@@ -458,7 +458,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format,
80913e
       if (len && len < 4)
80913e
         return gcry_error (GPG_ERR_TOO_SHORT);
80913e
 
80913e
-      n = (s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
80913e
+      n = ((size_t)s[0] << 24 | (size_t)s[1] << 16 | (size_t)s[2] << 8 | (size_t)s[3]);
80913e
       s += 4;
80913e
       if (len)
80913e
         len -= 4;