summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-bsp/grub/files/0037-loader-bsd-Check-for-NULL-arg-up-front.patch47
-rw-r--r--meta/recipes-bsp/grub/grub2.inc1
2 files changed, 48 insertions, 0 deletions
diff --git a/meta/recipes-bsp/grub/files/0037-loader-bsd-Check-for-NULL-arg-up-front.patch b/meta/recipes-bsp/grub/files/0037-loader-bsd-Check-for-NULL-arg-up-front.patch
new file mode 100644
index 0000000000..34643e10ab
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/0037-loader-bsd-Check-for-NULL-arg-up-front.patch
@@ -0,0 +1,47 @@
1From 7899384c8fdf9ed96566978c49b0c6e40e70703d Mon Sep 17 00:00:00 2001
2From: Darren Kenny <darren.kenny@oracle.com>
3Date: Tue, 8 Dec 2020 21:47:13 +0000
4Subject: [PATCH] loader/bsd: Check for NULL arg up-front
5
6The code in the next block suggests that it is possible for .set to be
7true but .arg may still be NULL.
8
9This code assumes that it is never NULL, yet later is testing if it is
10NULL - that is inconsistent.
11
12So we should check first if .arg is not NULL, and remove this check that
13is being flagged by Coverity since it is no longer required.
14
15Fixes: CID 292471
16
17Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
18Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
19
20Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=5d5391b0a05abe76e04c1eb68dcc6cbef5326c4a]
21Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
22---
23 grub-core/loader/i386/bsd.c | 4 ++--
24 1 file changed, 2 insertions(+), 2 deletions(-)
25
26diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c
27index b92cbe9..8432283 100644
28--- a/grub-core/loader/i386/bsd.c
29+++ b/grub-core/loader/i386/bsd.c
30@@ -1605,7 +1605,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
31 kernel_type = KERNEL_TYPE_OPENBSD;
32 bootflags = grub_bsd_parse_flags (ctxt->state, openbsd_flags);
33
34- if (ctxt->state[OPENBSD_ROOT_ARG].set)
35+ if (ctxt->state[OPENBSD_ROOT_ARG].set && ctxt->state[OPENBSD_ROOT_ARG].arg != NULL)
36 {
37 const char *arg = ctxt->state[OPENBSD_ROOT_ARG].arg;
38 unsigned type, unit, part;
39@@ -1622,7 +1622,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
40 "unknown disk type name");
41
42 unit = grub_strtoul (arg, (char **) &arg, 10);
43- if (! (arg && *arg >= 'a' && *arg <= 'z'))
44+ if (! (*arg >= 'a' && *arg <= 'z'))
45 return grub_error (GRUB_ERR_BAD_ARGUMENT,
46 "only device specifications of form "
47 "<type><number><lowercase letter> are supported");
diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc
index 1a4be33fca..8b55afccbb 100644
--- a/meta/recipes-bsp/grub/grub2.inc
+++ b/meta/recipes-bsp/grub/grub2.inc
@@ -83,6 +83,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
83 file://0034-video-fb-video_fb-Fix-possible-integer-overflow.patch \ 83 file://0034-video-fb-video_fb-Fix-possible-integer-overflow.patch \
84 file://0035-video-readers-jpeg-Test-for-an-invalid-next-marker-r.patch \ 84 file://0035-video-readers-jpeg-Test-for-an-invalid-next-marker-r.patch \
85 file://0036-gfxmenu-gui_list-Remove-code-that-coverity-is-flaggi.patch \ 85 file://0036-gfxmenu-gui_list-Remove-code-that-coverity-is-flaggi.patch \
86 file://0037-loader-bsd-Check-for-NULL-arg-up-front.patch \
86 " 87 "
87SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934" 88SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
88SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea" 89SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"