mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 01:19:52 +00:00
grub: fix incorrect use of a negative value
This patch adds a fix for an incorrect use of a negative value in grub's util/glue-efi. It is a part of a security series [1]. [1] https://lists.gnu.org/archive/html/grub-devel/2021-03/msg00007.html (From OE-Core rev: de1fe600212ff6d460bdc672d7ca0e13afbe7514) Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
6360727bb1
commit
9b69e69160
+50
@@ -0,0 +1,50 @@
|
||||
From e301a0f38a2130eb80f346c31e43bf5089af583c Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Fri, 4 Dec 2020 15:04:28 +0000
|
||||
Subject: [PATCH] util/glue-efi: Fix incorrect use of a possibly negative value
|
||||
|
||||
It is possible for the ftell() function to return a negative value,
|
||||
although it is fairly unlikely here, we should be checking for
|
||||
a negative value before we assign it to an unsigned value.
|
||||
|
||||
Fixes: CID 73744
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=1641d74e16f9d1ca35ba1a87ee4a0bf3afa48e72]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
util/glue-efi.c | 14 ++++++++++++--
|
||||
1 file changed, 12 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/util/glue-efi.c b/util/glue-efi.c
|
||||
index 68f5316..de0fa6d 100644
|
||||
--- a/util/glue-efi.c
|
||||
+++ b/util/glue-efi.c
|
||||
@@ -39,13 +39,23 @@ write_fat (FILE *in32, FILE *in64, FILE *out, const char *out_filename,
|
||||
struct grub_macho_fat_header head;
|
||||
struct grub_macho_fat_arch arch32, arch64;
|
||||
grub_uint32_t size32, size64;
|
||||
+ long size;
|
||||
char *buf;
|
||||
|
||||
fseek (in32, 0, SEEK_END);
|
||||
- size32 = ftell (in32);
|
||||
+ size = ftell (in32);
|
||||
+ if (size < 0)
|
||||
+ grub_util_error ("cannot get end of input file '%s': %s",
|
||||
+ name32, strerror (errno));
|
||||
+ size32 = (grub_uint32_t) size;
|
||||
fseek (in32, 0, SEEK_SET);
|
||||
+
|
||||
fseek (in64, 0, SEEK_END);
|
||||
- size64 = ftell (in64);
|
||||
+ size = ftell (in64);
|
||||
+ if (size < 0)
|
||||
+ grub_util_error ("cannot get end of input file '%s': %s",
|
||||
+ name64, strerror (errno));
|
||||
+ size64 = (grub_uint64_t) size;
|
||||
fseek (in64, 0, SEEK_SET);
|
||||
|
||||
head.magic = grub_cpu_to_le32_compile_time (GRUB_MACHO_FAT_EFI_MAGIC);
|
||||
@@ -89,6 +89,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
|
||||
file://0040-loader-xnu-Check-if-pointer-is-NULL-before-using-it.patch \
|
||||
file://0041-util-grub-install-Fix-NULL-pointer-dereferences.patch \
|
||||
file://0042-util-grub-editenv-Fix-incorrect-casting-of-a-signed-.patch \
|
||||
file://0043-util-glue-efi-Fix-incorrect-use-of-a-possibly-negati.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
|
||||
SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"
|
||||
|
||||
Reference in New Issue
Block a user