summaryrefslogtreecommitdiffstats
path: root/meta/recipes-bsp
diff options
context:
space:
mode:
authorMarta Rybczynska <rybczynska@gmail.com>2022-02-18 11:05:50 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-03-02 00:21:37 +0000
commit6360727bb14e05d316aaf575137c5c821f441e5f (patch)
tree6dc45fe1337bb3cdb202576dc554e0a68a83011c /meta/recipes-bsp
parent1a338ab46649328617df0a507663b3ca3d61110a (diff)
downloadpoky-6360727bb14e05d316aaf575137c5c821f441e5f.tar.gz
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>
Diffstat (limited to 'meta/recipes-bsp')
-rw-r--r--meta/recipes-bsp/grub/files/0042-util-grub-editenv-Fix-incorrect-casting-of-a-signed-.patch46
-rw-r--r--meta/recipes-bsp/grub/grub2.inc1
2 files changed, 47 insertions, 0 deletions
diff --git a/meta/recipes-bsp/grub/files/0042-util-grub-editenv-Fix-incorrect-casting-of-a-signed-.patch b/meta/recipes-bsp/grub/files/0042-util-grub-editenv-Fix-incorrect-casting-of-a-signed-.patch
new file mode 100644
index 0000000000..0cd8ec3611
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/0042-util-grub-editenv-Fix-incorrect-casting-of-a-signed-.patch
@@ -0,0 +1,46 @@
1From 3d68daf2567aace4b52bd238cfd4a8111af3bc04 Mon Sep 17 00:00:00 2001
2From: Darren Kenny <darren.kenny@oracle.com>
3Date: Thu, 5 Nov 2020 14:33:50 +0000
4Subject: [PATCH] util/grub-editenv: Fix incorrect casting of a signed value
5
6The return value of ftell() may be negative (-1) on error. While it is
7probably unlikely to occur, we should not blindly cast to an unsigned
8value without first testing that it is not negative.
9
10Fixes: CID 73856
11
12Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
13Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
14
15Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=5dc41edc4eba259c6043ae7698c245ec1baaacc6]
16Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
17---
18 util/grub-editenv.c | 8 +++++++-
19 1 file changed, 7 insertions(+), 1 deletion(-)
20
21diff --git a/util/grub-editenv.c b/util/grub-editenv.c
22index f3662c9..db6f187 100644
23--- a/util/grub-editenv.c
24+++ b/util/grub-editenv.c
25@@ -125,6 +125,7 @@ open_envblk_file (const char *name)
26 {
27 FILE *fp;
28 char *buf;
29+ long loc;
30 size_t size;
31 grub_envblk_t envblk;
32
33@@ -143,7 +144,12 @@ open_envblk_file (const char *name)
34 grub_util_error (_("cannot seek `%s': %s"), name,
35 strerror (errno));
36
37- size = (size_t) ftell (fp);
38+ loc = ftell (fp);
39+ if (loc < 0)
40+ grub_util_error (_("cannot get file location `%s': %s"), name,
41+ strerror (errno));
42+
43+ size = (size_t) loc;
44
45 if (fseek (fp, 0, SEEK_SET) < 0)
46 grub_util_error (_("cannot seek `%s': %s"), name,
diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc
index 7ca0b469e9..a1fbc5e644 100644
--- a/meta/recipes-bsp/grub/grub2.inc
+++ b/meta/recipes-bsp/grub/grub2.inc
@@ -88,6 +88,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
88 file://0039-loader-xnu-Free-driverkey-data-when-an-error-is-dete.patch \ 88 file://0039-loader-xnu-Free-driverkey-data-when-an-error-is-dete.patch \
89 file://0040-loader-xnu-Check-if-pointer-is-NULL-before-using-it.patch \ 89 file://0040-loader-xnu-Check-if-pointer-is-NULL-before-using-it.patch \
90 file://0041-util-grub-install-Fix-NULL-pointer-dereferences.patch \ 90 file://0041-util-grub-install-Fix-NULL-pointer-dereferences.patch \
91 file://0042-util-grub-editenv-Fix-incorrect-casting-of-a-signed-.patch \
91 " 92 "
92SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934" 93SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
93SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea" 94SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"