diff --git a/backport-Add-missing-short-option-handling-for-index-I.patch b/backport-Add-missing-short-option-handling-for-index-I.patch new file mode 100644 index 0000000000000000000000000000000000000000..46794e3cc0acfda04d65da1097f0e18ec7283014 --- /dev/null +++ b/backport-Add-missing-short-option-handling-for-index-I.patch @@ -0,0 +1,26 @@ +From b0f81089481c10af6e6ac404755830fefee60e93 Mon Sep 17 00:00:00 2001 +From: kamillo +Date: Fri, 17 Feb 2023 21:55:17 +0100 +Subject: [PATCH] Add missing short option handling for --index (-I) + +Signed-off-by: kamillo +--- + src/efibootmgr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/efibootmgr.c b/src/efibootmgr.c +index 4b15d6d..255f61f 100644 +--- a/src/efibootmgr.c ++++ b/src/efibootmgr.c +@@ -1509,7 +1509,7 @@ parse_opts(int argc, char **argv) + }; + + c = getopt_long(argc, argv, +- "aAb:BcCd:De:E:fFgi:kl:L:m:M:n:No:Op:qrt:Tuv::Vwy@:h", ++ "aAb:BcCd:De:E:fFgi:I:kl:L:m:M:n:No:Op:qrt:Tuv::Vwy@:h", + long_options, &option_index); + if (c == -1) + break; +-- +2.27.0 + diff --git a/backport-Fix-segfault-when-passed-index-is-greater-than-curre.patch b/backport-Fix-segfault-when-passed-index-is-greater-than-curre.patch new file mode 100644 index 0000000000000000000000000000000000000000..4ee64586b83cb615ae8c169cb652369a7ecf07a8 --- /dev/null +++ b/backport-Fix-segfault-when-passed-index-is-greater-than-curre.patch @@ -0,0 +1,31 @@ +From 4a8d9c69050bd01a0be66695fea3b35b72f5a425 Mon Sep 17 00:00:00 2001 +From: kamillo +Date: Fri, 17 Feb 2023 22:02:22 +0100 +Subject: [PATCH] Fix segfault when passed --index is greater than current + boot order size + +Size of the order entry size (uint16_t) hasn't been taken into account for all calculations and caused memory corruption. + +Signed-off-by: kamillo +--- + src/efibootmgr.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/efibootmgr.c b/src/efibootmgr.c +index 255f61f..ded21a1 100644 +--- a/src/efibootmgr.c ++++ b/src/efibootmgr.c +@@ -420,8 +420,8 @@ add_to_order(const char *name, uint16_t num, uint16_t insert_at) + return -1; + + if (insert_at != 0) { +- if (insert_at > order->data_size) +- insert_at = order->data_size; ++ if (insert_at * sizeof(uint16_t) > order->data_size) ++ insert_at = order->data_size / sizeof(uint16_t); + memcpy(new_data, old_data, insert_at * sizeof(uint16_t)); + } + new_data[insert_at] = num; +-- +2.27.0 + diff --git a/efibootmgr.spec b/efibootmgr.spec index 6a2385f7ded50db64d9707a4828b6cb893b3b1c9..bf0cba7fc47f83d97e1980939d223aa36d43cc44 100644 --- a/efibootmgr.spec +++ b/efibootmgr.spec @@ -1,5 +1,5 @@ Name: efibootmgr -Release: 3 +Release: 4 Version: 18 Summary: A tool manipulating the EFI Boot Manager License: GPLv2+ @@ -7,6 +7,8 @@ URL: https://github.com/rhboot/%{name}/ Source0: https://github.com/rhboot/%{name}/archive/refs/tags/%{version}.tar.gz Patch6000: backport-Update-efibootmgr.c.patch +Patch6001: backport-Add-missing-short-option-handling-for-index-I.patch +Patch6002: backport-Fix-segfault-when-passed-index-is-greater-than-curre.patch BuildRequires: gcc BuildRequires: efi-srpm-macros >= 3-2 efi-filesystem git popt-devel efivar-libs >= 38-1 efivar-devel >= 38-1 @@ -48,6 +50,10 @@ rm -rf %{buildroot} %{_mandir}/*/*.?.gz %changelog +* Mon Mar 13 2023 zhangqiumiao - 18-4 +- Fix segfault when passed --index is greater than current boot order size + Add missing short option handling for --index (-I) + * Mon Feb 20 2023 zhangqiumiao - 18-3 - get_entry: return entry if it was found before reaching the end of the list