diff options
Diffstat (limited to 'meta/recipes-bsp/grub/files/0042-util-grub-editenv-Fix-incorrect-casting-of-a-signed-.patch')
-rw-r--r-- | meta/recipes-bsp/grub/files/0042-util-grub-editenv-Fix-incorrect-casting-of-a-signed-.patch | 46 |
1 files changed, 46 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 @@ | |||
1 | From 3d68daf2567aace4b52bd238cfd4a8111af3bc04 Mon Sep 17 00:00:00 2001 | ||
2 | From: Darren Kenny <darren.kenny@oracle.com> | ||
3 | Date: Thu, 5 Nov 2020 14:33:50 +0000 | ||
4 | Subject: [PATCH] util/grub-editenv: Fix incorrect casting of a signed value | ||
5 | |||
6 | The return value of ftell() may be negative (-1) on error. While it is | ||
7 | probably unlikely to occur, we should not blindly cast to an unsigned | ||
8 | value without first testing that it is not negative. | ||
9 | |||
10 | Fixes: CID 73856 | ||
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=5dc41edc4eba259c6043ae7698c245ec1baaacc6] | ||
16 | Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> | ||
17 | --- | ||
18 | util/grub-editenv.c | 8 +++++++- | ||
19 | 1 file changed, 7 insertions(+), 1 deletion(-) | ||
20 | |||
21 | diff --git a/util/grub-editenv.c b/util/grub-editenv.c | ||
22 | index 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, | ||