mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 01:19:52 +00:00
grub: add a fix for an incorrect cast
This patch adds a fix for incorrect casting from signed to unsigned in grub's util/grub-editenv. 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: 906ecdc9efbc1b4025c2c7a9797ebd374f8508af) 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
1a338ab466
commit
6360727bb1
+46
@@ -0,0 +1,46 @@
|
||||
From 3d68daf2567aace4b52bd238cfd4a8111af3bc04 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 5 Nov 2020 14:33:50 +0000
|
||||
Subject: [PATCH] util/grub-editenv: Fix incorrect casting of a signed value
|
||||
|
||||
The return value of ftell() may be negative (-1) on error. While it is
|
||||
probably unlikely to occur, we should not blindly cast to an unsigned
|
||||
value without first testing that it is not negative.
|
||||
|
||||
Fixes: CID 73856
|
||||
|
||||
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=5dc41edc4eba259c6043ae7698c245ec1baaacc6]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
util/grub-editenv.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/util/grub-editenv.c b/util/grub-editenv.c
|
||||
index f3662c9..db6f187 100644
|
||||
--- a/util/grub-editenv.c
|
||||
+++ b/util/grub-editenv.c
|
||||
@@ -125,6 +125,7 @@ open_envblk_file (const char *name)
|
||||
{
|
||||
FILE *fp;
|
||||
char *buf;
|
||||
+ long loc;
|
||||
size_t size;
|
||||
grub_envblk_t envblk;
|
||||
|
||||
@@ -143,7 +144,12 @@ open_envblk_file (const char *name)
|
||||
grub_util_error (_("cannot seek `%s': %s"), name,
|
||||
strerror (errno));
|
||||
|
||||
- size = (size_t) ftell (fp);
|
||||
+ loc = ftell (fp);
|
||||
+ if (loc < 0)
|
||||
+ grub_util_error (_("cannot get file location `%s': %s"), name,
|
||||
+ strerror (errno));
|
||||
+
|
||||
+ size = (size_t) loc;
|
||||
|
||||
if (fseek (fp, 0, SEEK_SET) < 0)
|
||||
grub_util_error (_("cannot seek `%s': %s"), name,
|
||||
@@ -88,6 +88,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
|
||||
file://0039-loader-xnu-Free-driverkey-data-when-an-error-is-dete.patch \
|
||||
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 \
|
||||
"
|
||||
SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
|
||||
SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"
|
||||
|
||||
Reference in New Issue
Block a user