diff options
Diffstat (limited to 'meta/recipes-bsp/grub/files/0043-util-glue-efi-Fix-incorrect-use-of-a-possibly-negati.patch')
-rw-r--r-- | meta/recipes-bsp/grub/files/0043-util-glue-efi-Fix-incorrect-use-of-a-possibly-negati.patch | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/meta/recipes-bsp/grub/files/0043-util-glue-efi-Fix-incorrect-use-of-a-possibly-negati.patch b/meta/recipes-bsp/grub/files/0043-util-glue-efi-Fix-incorrect-use-of-a-possibly-negati.patch new file mode 100644 index 0000000000..66d7c0aa42 --- /dev/null +++ b/meta/recipes-bsp/grub/files/0043-util-glue-efi-Fix-incorrect-use-of-a-possibly-negati.patch | |||
@@ -0,0 +1,50 @@ | |||
1 | From e301a0f38a2130eb80f346c31e43bf5089af583c Mon Sep 17 00:00:00 2001 | ||
2 | From: Darren Kenny <darren.kenny@oracle.com> | ||
3 | Date: Fri, 4 Dec 2020 15:04:28 +0000 | ||
4 | Subject: [PATCH] util/glue-efi: Fix incorrect use of a possibly negative value | ||
5 | |||
6 | It is possible for the ftell() function to return a negative value, | ||
7 | although it is fairly unlikely here, we should be checking for | ||
8 | a negative value before we assign it to an unsigned value. | ||
9 | |||
10 | Fixes: CID 73744 | ||
11 | |||
12 | Signed-off-by: Darren Kenny <darren.kenny@oracle.com> | ||
13 | Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> | ||
14 | |||
15 | Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=1641d74e16f9d1ca35ba1a87ee4a0bf3afa48e72] | ||
16 | Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> | ||
17 | --- | ||
18 | util/glue-efi.c | 14 ++++++++++++-- | ||
19 | 1 file changed, 12 insertions(+), 2 deletions(-) | ||
20 | |||
21 | diff --git a/util/glue-efi.c b/util/glue-efi.c | ||
22 | index 68f5316..de0fa6d 100644 | ||
23 | --- a/util/glue-efi.c | ||
24 | +++ b/util/glue-efi.c | ||
25 | @@ -39,13 +39,23 @@ write_fat (FILE *in32, FILE *in64, FILE *out, const char *out_filename, | ||
26 | struct grub_macho_fat_header head; | ||
27 | struct grub_macho_fat_arch arch32, arch64; | ||
28 | grub_uint32_t size32, size64; | ||
29 | + long size; | ||
30 | char *buf; | ||
31 | |||
32 | fseek (in32, 0, SEEK_END); | ||
33 | - size32 = ftell (in32); | ||
34 | + size = ftell (in32); | ||
35 | + if (size < 0) | ||
36 | + grub_util_error ("cannot get end of input file '%s': %s", | ||
37 | + name32, strerror (errno)); | ||
38 | + size32 = (grub_uint32_t) size; | ||
39 | fseek (in32, 0, SEEK_SET); | ||
40 | + | ||
41 | fseek (in64, 0, SEEK_END); | ||
42 | - size64 = ftell (in64); | ||
43 | + size = ftell (in64); | ||
44 | + if (size < 0) | ||
45 | + grub_util_error ("cannot get end of input file '%s': %s", | ||
46 | + name64, strerror (errno)); | ||
47 | + size64 = (grub_uint64_t) size; | ||
48 | fseek (in64, 0, SEEK_SET); | ||
49 | |||
50 | head.magic = grub_cpu_to_le32_compile_time (GRUB_MACHO_FAT_EFI_MAGIC); | ||