From 43d56782c2572a9d30f15410f74167fef95e5084 Mon Sep 17 00:00:00 2001 From: shirely16 Date: Tue, 8 Jun 2021 11:49:45 +0800 Subject: [PATCH] round community patches fix memory leak (cherry picked from commit 1e0683011c23f0d8802ef0e4cba65f64d9a31ddd) --- ...-memory-leak-of-deleted-boot-entries.patch | 44 +++++++++++++++++++ efibootmgr.spec | 6 ++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 backport-get-rid-of-a-memory-leak-of-deleted-boot-entries.patch diff --git a/backport-get-rid-of-a-memory-leak-of-deleted-boot-entries.patch b/backport-get-rid-of-a-memory-leak-of-deleted-boot-entries.patch new file mode 100644 index 0000000..efdef67 --- /dev/null +++ b/backport-get-rid-of-a-memory-leak-of-deleted-boot-entries.patch @@ -0,0 +1,44 @@ +From d9eb7f1536ed6262fc8c6518c6afe6053a450e9d Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 28 May 2019 17:00:31 -0400 +Subject: [PATCH] Get rid of a memory leak of deleted boot entries. + +Signed-off-by: Peter Jones + +Conflict:NA +Reference:https://github.com/rhboot/efibootmgr/commit/d9eb7f1536ed6262fc8c6518c6afe6053a450e9d +--- + src/efibootmgr.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/src/efibootmgr.c b/src/efibootmgr.c +index 19a6edc..afcfc77 100644 +--- a/src/efibootmgr.c ++++ b/src/efibootmgr.c +@@ -106,13 +106,12 @@ read_vars(char **namelist, + + for (i=0; namelist[i] != NULL; i++) { + if (namelist[i]) { +- entry = malloc(sizeof(var_entry_t)); ++ entry = calloc(1, sizeof(var_entry_t)); + if (!entry) { +- efi_error("malloc(%zd) failed", ++ efi_error("calloc(1, %zd) failed", + sizeof(var_entry_t)); + goto err; + } +- memset(entry, 0, sizeof(var_entry_t)); + + rc = efi_get_variable(EFI_GLOBAL_GUID, namelist[i], + &entry->data, &entry->data_size, +@@ -611,6 +610,10 @@ delete_var(const char *prefix, uint16_t num) + return rc; + } + list_del(&(entry->list)); ++ free(entry->name); ++ free(entry->data); ++ memset(entry, 0, sizeof(*entry)); ++ free(entry); + break; /* short-circuit since it was found */ + } + } diff --git a/efibootmgr.spec b/efibootmgr.spec index dcc125e..08ed661 100644 --- a/efibootmgr.spec +++ b/efibootmgr.spec @@ -1,5 +1,5 @@ Name: efibootmgr -Release: 1 +Release: 2 Version: 17 Summary: A tool manipulating the EFI Boot Manager License: GPLv2+ @@ -7,6 +7,7 @@ URL: https://github.com/rhboot/%{name}/ Source0: https://github.com/rhboot/%{name}/releases/download/%{name}-%{version}/%{name}-%{version}.tar.gz Patch0: remove_extra_decl.patch +Patch6000: backport-get-rid-of-a-memory-leak-of-deleted-boot-entries.patch BuildRequires: efi-srpm-macros >= 3-2 efi-filesystem git popt-devel efivar-libs >= 35-2 efivar-devel >= 35-2 Requires: efi-filesystem @@ -47,6 +48,9 @@ rm -rf %{buildroot} %{_mandir}/*/*.?.gz %changelog +* Tue Jun 8 2021 hanhui - 17-2 +- round community patches fix memory leak + * Sat Aug 29 2020 yuboyun - 17-1 - update to 17 -- Gitee