mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 00:49:33 +02:00
grub: add a fix for a memory leak
This patch adds a fix for a memory leak in grub's normal/completion. 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: e58e6e646c2efb91dba3ffa6db3a43b7972f0c87) 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
4c7bfa8abe
commit
bd3bda5d03
@@ -0,0 +1,52 @@
|
|||||||
|
From 2367049d2021e00d82d19cee923e06a4b04ebc30 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Darren Kenny <darren.kenny@oracle.com>
|
||||||
|
Date: Fri, 4 Dec 2020 18:56:48 +0000
|
||||||
|
Subject: [PATCH] normal/completion: Fix leaking of memory when processing a
|
||||||
|
completion
|
||||||
|
|
||||||
|
It is possible for the code to reach the end of the function without
|
||||||
|
freeing the memory allocated to argv and argc still to be 0.
|
||||||
|
|
||||||
|
We should always call grub_free(argv). The grub_free() will handle
|
||||||
|
a NULL argument correctly if it reaches that code without the memory
|
||||||
|
being allocated.
|
||||||
|
|
||||||
|
Fixes: CID 96672
|
||||||
|
|
||||||
|
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=9213575b7a95b514bce80be5964a28d407d7d56d]
|
||||||
|
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||||
|
---
|
||||||
|
grub-core/normal/completion.c | 10 ++++------
|
||||||
|
1 file changed, 4 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/grub-core/normal/completion.c b/grub-core/normal/completion.c
|
||||||
|
index 5961028..46e473c 100644
|
||||||
|
--- a/grub-core/normal/completion.c
|
||||||
|
+++ b/grub-core/normal/completion.c
|
||||||
|
@@ -400,8 +400,8 @@ char *
|
||||||
|
grub_normal_do_completion (char *buf, int *restore,
|
||||||
|
void (*hook) (const char *, grub_completion_type_t, int))
|
||||||
|
{
|
||||||
|
- int argc;
|
||||||
|
- char **argv;
|
||||||
|
+ int argc = 0;
|
||||||
|
+ char **argv = NULL;
|
||||||
|
|
||||||
|
/* Initialize variables. */
|
||||||
|
match = 0;
|
||||||
|
@@ -516,10 +516,8 @@ grub_normal_do_completion (char *buf, int *restore,
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (argc != 0)
|
||||||
|
- {
|
||||||
|
- grub_free (argv[0]);
|
||||||
|
- grub_free (argv);
|
||||||
|
- }
|
||||||
|
+ grub_free (argv[0]);
|
||||||
|
+ grub_free (argv);
|
||||||
|
grub_free (match);
|
||||||
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
|
||||||
@@ -75,6 +75,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
|
|||||||
file://0026-libgcrypt-mpi-Fix-possible-unintended-sign-extension.patch \
|
file://0026-libgcrypt-mpi-Fix-possible-unintended-sign-extension.patch \
|
||||||
file://0027-libgcrypt-mpi-Fix-possible-NULL-dereference.patch \
|
file://0027-libgcrypt-mpi-Fix-possible-NULL-dereference.patch \
|
||||||
file://0028-syslinux-Fix-memory-leak-while-parsing.patch \
|
file://0028-syslinux-Fix-memory-leak-while-parsing.patch \
|
||||||
|
file://0029-normal-completion-Fix-leaking-of-memory-when-process.patch \
|
||||||
"
|
"
|
||||||
SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
|
SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
|
||||||
SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"
|
SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"
|
||||||
|
|||||||
Reference in New Issue
Block a user