Fix invalid free in main()

(cherry picked from commit ca20bd3af788b77380796daf9ce7ce216dd0246a)
This commit is contained in:
sherlock2010 2024-03-13 06:27:39 +00:00 committed by openeuler-sync-bot
parent eccf277852
commit e1d56b13ac
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,29 @@
From 6be2cb1c0139ac177e754b0767abf1ca1533847f Mon Sep 17 00:00:00 2001
From: Robbie Harwood <rharwood@redhat.com>
Date: Mon, 18 Apr 2022 13:08:18 -0400
Subject: [PATCH] Fix invalid free in main()
data is allocated by mmap() in prepare_data().
Resolves: #173
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Conflict:NA
Reference:https://github.com/rhboot/efivar/commit/6be2cb1c0139ac177e754b0767abf1ca1533847f
---
src/efivar.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/efivar.c b/src/efivar.c
index 5cd1eb2b..09f85edd 100644
--- a/src/efivar.c
+++ b/src/efivar.c
@@ -633,7 +633,7 @@ int main(int argc, char *argv[])
if (sz < 0)
err(1, "Could not import data from \"%s\"", infile);
- free(data);
+ munmap(data, data_size);
data = NULL;
data_size = 0;

View File

@ -1,6 +1,6 @@
Name: efivar
Version: 38
Release: 3
Release: 4
Summary: Tools and libraries to work with EFI variables
License: LGPL-2.1-only
URL: https://github.com/rhboot/%{name}
@ -12,6 +12,7 @@ Patch0002: 0002-Fix-glibc-2.36-build-mount.h-conflicts.patch
Patch0003: efivar-37-sw.patch
%endif
Patch9000: dp_h-check-_ucs2size-in-format_ucs2.patch
Patch9001: backport-Fix-invalid-free-in-main.patch
BuildRequires: popt-devel glibc-static
BuildRequires: gcc mandoc
@ -73,6 +74,12 @@ install -m 0644 src/abignore %{buildroot}%{_includedir}/efivar/.abignore
%{_mandir}/man3/*
%changelog
* Wed Mar 13 2024 zhouyihang <zhouyihang3@h-partners.com> - 38-4
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Fix invalid free in main()
* Tue Sep 12 2023 zhangqiumiao <zhangqiumiao1@huawei.com> - 38-3
- Type:bugfix
- ID:NA