diff options
Diffstat (limited to 'meta/recipes-bsp/grub/files/0026-libgcrypt-mpi-Fix-possible-unintended-sign-extension.patch')
-rw-r--r-- | meta/recipes-bsp/grub/files/0026-libgcrypt-mpi-Fix-possible-unintended-sign-extension.patch | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/meta/recipes-bsp/grub/files/0026-libgcrypt-mpi-Fix-possible-unintended-sign-extension.patch b/meta/recipes-bsp/grub/files/0026-libgcrypt-mpi-Fix-possible-unintended-sign-extension.patch new file mode 100644 index 0000000000..f500f1a296 --- /dev/null +++ b/meta/recipes-bsp/grub/files/0026-libgcrypt-mpi-Fix-possible-unintended-sign-extension.patch | |||
@@ -0,0 +1,36 @@ | |||
1 | From 9b16d7bcad1c7fea7f26eb2fb3af1a5ca70ba34e Mon Sep 17 00:00:00 2001 | ||
2 | From: Darren Kenny <darren.kenny@oracle.com> | ||
3 | Date: Tue, 3 Nov 2020 16:43:37 +0000 | ||
4 | Subject: [PATCH] libgcrypt/mpi: Fix possible unintended sign extension | ||
5 | |||
6 | The array of unsigned char gets promoted to a signed 32-bit int before | ||
7 | it is finally promoted to a size_t. There is the possibility that this | ||
8 | may result in the signed-bit being set for the intermediate signed | ||
9 | 32-bit int. We should ensure that the promotion is to the correct type | ||
10 | before we bitwise-OR the values. | ||
11 | |||
12 | Fixes: CID 96697 | ||
13 | |||
14 | Signed-off-by: Darren Kenny <darren.kenny@oracle.com> | ||
15 | Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> | ||
16 | |||
17 | Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=e8814c811132a70f9b55418f7567378a34ad3883] | ||
18 | Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> | ||
19 | |||
20 | --- | ||
21 | grub-core/lib/libgcrypt/mpi/mpicoder.c | 2 +- | ||
22 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
23 | |||
24 | diff --git a/grub-core/lib/libgcrypt/mpi/mpicoder.c b/grub-core/lib/libgcrypt/mpi/mpicoder.c | ||
25 | index a3435ed..7ecad27 100644 | ||
26 | --- a/grub-core/lib/libgcrypt/mpi/mpicoder.c | ||
27 | +++ b/grub-core/lib/libgcrypt/mpi/mpicoder.c | ||
28 | @@ -458,7 +458,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format, | ||
29 | if (len && len < 4) | ||
30 | return gcry_error (GPG_ERR_TOO_SHORT); | ||
31 | |||
32 | - n = (s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]); | ||
33 | + n = ((size_t)s[0] << 24 | (size_t)s[1] << 16 | (size_t)s[2] << 8 | (size_t)s[3]); | ||
34 | s += 4; | ||
35 | if (len) | ||
36 | len -= 4; | ||