diff --git a/.efibootmgr.metadata b/.efibootmgr.metadata index 9e6b5cf..91c1b59 100644 --- a/.efibootmgr.metadata +++ b/.efibootmgr.metadata @@ -1 +1 @@ -cb7ff114d22f99ba7e386abd777cb78c28c37575 SOURCES/efibootmgr-0.8.0.tar.bz2 +9dc7ca7b14a47fc178a5bb7b9c0a79cc05e2b272 SOURCES/efibootmgr-15.tar.bz2 diff --git a/.gitignore b/.gitignore index 3654103..c2eb4e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/efibootmgr-0.8.0.tar.bz2 +SOURCES/efibootmgr-15.tar.bz2 diff --git a/SOURCES/0001-Make-EFI-redhat-shim.efi-the-default-bootloader.patch b/SOURCES/0001-Make-EFI-redhat-shim.efi-the-default-bootloader.patch deleted file mode 100644 index 2fd8947..0000000 --- a/SOURCES/0001-Make-EFI-redhat-shim.efi-the-default-bootloader.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 183ca3ad59a192e0a6de25e1cc08905ae3e1ae67 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 14 Apr 2010 16:06:48 -0400 -Subject: [PATCH 01/31] Make \EFI\redhat\shim.efi the default bootloader - -Make \EFI\redhat\shim.efi the default bootloader instead of \elilo.efi . ---- - src/efibootmgr/efibootmgr.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index 5af2cad..c2c7284 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -18,7 +18,7 @@ - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -- This must tie the EFI_DEVICE_PATH to /boot/efi/EFI/redhat/grub.efi -+ This must tie the EFI_DEVICE_PATH to /boot/efi/EFI/redhat/shim.efi - The EFI_DEVICE_PATH will look something like: - ACPI device path, length 12 bytes - Hardware Device Path, PCI, length 6 bytes -@@ -893,7 +893,7 @@ usage() - printf("\t-g | --gpt force disk with invalid PMBR to be treated as GPT\n"); - printf("\t-H | --acpi_hid XXXX set the ACPI HID (used with -i)\n"); - printf("\t-i | --iface name create a netboot entry for the named interface\n"); -- printf("\t-l | --loader name (defaults to \\EFI\\redhat\\grub.efi)\n"); -+ printf("\t-l | --loader name (defaults to \\EFI\\redhat\\shim.efi)\n"); - printf("\t-L | --label label Boot manager display label (defaults to \"Linux\")\n"); - printf("\t-n | --bootnext XXXX set BootNext to XXXX (hex)\n"); - printf("\t-N | --delete-bootnext delete BootNext\n"); -@@ -921,7 +921,7 @@ set_default_opts() - opts.active = -1; /* Don't set it */ - opts.timeout = -1; /* Don't set it */ - opts.edd10_devicenum = 0x80; -- opts.loader = "\\EFI\\redhat\\grub.efi"; -+ opts.loader = "\\EFI\\redhat\\shim.efi"; - opts.label = "Linux"; - opts.disk = "/dev/sda"; - opts.iface = NULL; --- -2.7.4 - diff --git a/SOURCES/0001-RHEL-7.x-popt-doesn-t-have-popt.pc-work-around-its-a.patch b/SOURCES/0001-RHEL-7.x-popt-doesn-t-have-popt.pc-work-around-its-a.patch new file mode 100644 index 0000000..0e6d03a --- /dev/null +++ b/SOURCES/0001-RHEL-7.x-popt-doesn-t-have-popt.pc-work-around-its-a.patch @@ -0,0 +1,43 @@ +From ad4f7b2b46aadb402dbfb1197151446d10c8ec6e Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 13 Mar 2017 15:33:54 -0400 +Subject: [PATCH 1/2] RHEL 7.x popt doesn't have popt.pc, work around its + absense. + +Related: rhbz#1380825 + +Signed-off-by: Peter Jones +--- + src/Makefile | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/Makefile b/src/Makefile +index 258bac1..453ddad 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -21,15 +21,19 @@ ALL_SOURCES=$(EFIBOOTMGR_SOURCES) + + efibootmgr : $(call objects-of,$(EFIBOOTMGR_SOURCES)) + efibootmgr : PKGS=efivar efiboot ++efibootmgr : LIBS=popt + + eficonman : $(call objects-of,$(EFICONMAN_SOURCES)) +-eficonman : PKGS=efivar efiboot popt ++eficonman : PKGS=efivar efiboot ++eficonman : LIBS=popt + + efibootdump : $(call objects-of,$(EFIBOOTDUMP_SOURCES)) +-efibootdump : PKGS=efivar efiboot popt ++efibootdump : PKGS=efivar efiboot ++efibootdump : LIBS=popt + + efibootnext : $(call objects-of,$(EFIBOOTNEXT_SOURCES)) +-efibootnext : PKGS=efivar efiboot popt ++efibootnext : PKGS=efivar efiboot ++efibootnext : LIBS=popt + + deps : $(ALL_SOURCES) + $(MAKE) -f $(TOPDIR)/Make.deps deps SOURCES="$(ALL_SOURCES)" SUBDIR_CFLAGS="$(SUBDIR_CFLAGS)" +-- +2.9.3 + diff --git a/SOURCES/0002-Don-t-build-efibootdump-on-RHEL-7.4.patch b/SOURCES/0002-Don-t-build-efibootdump-on-RHEL-7.4.patch new file mode 100644 index 0000000..e6f576f --- /dev/null +++ b/SOURCES/0002-Don-t-build-efibootdump-on-RHEL-7.4.patch @@ -0,0 +1,41 @@ +From 09df652105eb466390c00b8599d777e6fed45c41 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 13 Mar 2017 15:48:09 -0400 +Subject: [PATCH 2/2] Don't build efibootdump on RHEL 7.4... + +Because popt is ancient (1.13 released in 2007, as opposed to 1.16 +released in 2010), it does not have POPT_ARG_ARGV, which efibootdump +uses. Since there's no feature for efibootdump, and we've never shipped +it, just nerf it out of the build. + +Signed-off-by: Peter Jones +--- + src/Makefile | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/src/Makefile b/src/Makefile +index 453ddad..162f552 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -7,7 +7,7 @@ include $(TOPDIR)/Make.defaults + + SUBDIR_CFLAGS = -I$(SRCDIR)/include + +-BINTARGETS=efibootmgr efibootdump ++BINTARGETS=efibootmgr + TARGETS=$(BINTARGETS) + + all : deps $(TARGETS) +@@ -45,9 +45,7 @@ clean : + install : + $(INSTALL) -d -m 755 $(DESTDIR)/$(sbindir)/ + $(INSTALL) -m 755 efibootmgr $(DESTDIR)/$(sbindir)/efibootmgr +- $(INSTALL) -m 755 efibootdump $(DESTDIR)/$(sbindir)/efibootdump + $(INSTALL) -d -m 755 $(DESTDIR)/$(mandir)/man8/ + $(INSTALL) -m 644 efibootmgr.8 $(DESTDIR)/$(mandir)/man8/efibootmgr.8 +- $(INSTALL) -m 644 efibootdump.8 $(DESTDIR)/$(mandir)/man8/efibootdump.8 + + .PHONY : all deps clean install +-- +2.9.3 + diff --git a/SOURCES/0002-Fix-a-bad-allocation-size.patch b/SOURCES/0002-Fix-a-bad-allocation-size.patch deleted file mode 100644 index 576f52e..0000000 --- a/SOURCES/0002-Fix-a-bad-allocation-size.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 340766d4d1a745723e9ef53dd3f6b6c175203638 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 15:27:02 -0400 -Subject: [PATCH 02/31] Fix a bad allocation size. - -Covscan found this. - -Signed-off-by: Peter Jones ---- - src/lib/efi.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/lib/efi.c b/src/lib/efi.c -index 133b8bb..6b25dfe 100644 ---- a/src/lib/efi.c -+++ b/src/lib/efi.c -@@ -717,7 +717,7 @@ make_linux_load_option(uint8_t **data, size_t *data_size) - size_t needed; - off_t buf_offset = 0, desc_offset; - -- load_option = calloc(1, sizeof (load_option)); -+ load_option = calloc(1, sizeof (*load_option)); - if (load_option == NULL) - return -1; - buf = (uint8_t *)load_option; --- -2.7.4 - diff --git a/SOURCES/0003-Make-the-return-path-something-coverity-can-actually.patch b/SOURCES/0003-Make-the-return-path-something-coverity-can-actually.patch deleted file mode 100644 index 4b66370..0000000 --- a/SOURCES/0003-Make-the-return-path-something-coverity-can-actually.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 397a7b6d58f3d4ae264795a3925234266069b1c5 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 15:29:43 -0400 -Subject: [PATCH 03/31] Make the return path something coverity can actually - understand. - -It was *correct* before, but there's no reason to do it that weird way. - -Signed-off-by: Peter Jones ---- - src/efibootmgr/efibootmgr.c | 17 ++++++++++------- - 1 file changed, 10 insertions(+), 7 deletions(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index c2c7284..5ca97ab 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -805,14 +805,17 @@ show_boot_order() - - rc = read_boot_order(&boot_order); - -- if (rc < 0 && errno == ENOENT) { -- boot_order = calloc(1, sizeof (*boot_order)); -- rc = boot_order ? 0 : -1; -- } -- - if (rc < 0) { -- perror("show_boot_order()"); -- return; -+ if (errno == ENOENT) { -+ boot_order = calloc(1, sizeof (*boot_order)); -+ if (!boot_order) { -+ perror("show_boot_order()"); -+ return; -+ } -+ } else { -+ perror("show_boot_order()"); -+ return; -+ } - } - - /* We've now got an array (in boot_order->data) of the --- -2.7.4 - diff --git a/SOURCES/0003-make_linux_load_option-check-data_size-correctly.patch b/SOURCES/0003-make_linux_load_option-check-data_size-correctly.patch new file mode 100644 index 0000000..b679be2 --- /dev/null +++ b/SOURCES/0003-make_linux_load_option-check-data_size-correctly.patch @@ -0,0 +1,33 @@ +From 2e018c08b92c800961ec010a6a4eeb34e8f3faa0 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 9 May 2017 16:46:13 -0400 +Subject: [PATCH 3/4] make_linux_load_option(): check data_size correctly. + +Coverity noticed that we're not checking data_size for NULLness before +dereferencing it to pass the value to efi_loadopt_create(). So now we +pass a temporary variable and assign it only if it's non-NULL. + +Signed-off-by: Peter Jones +--- + src/efi.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/efi.c b/src/efi.c +index 8e2664e..cf4ada6 100644 +--- a/src/efi.c ++++ b/src/efi.c +@@ -397,7 +397,10 @@ make_linux_load_option(uint8_t **data, size_t *data_size, + } + } + +- needed = efi_loadopt_create(*data, *data_size, ++ size_t data_size_tmp = 0; ++ if (data_size) ++ data_size_tmp = *data_size; ++ needed = efi_loadopt_create(*data, data_size_tmp, + attributes, dp, needed, opts.label, + optional_data, optional_data_size); + if (dp) { +-- +2.12.2 + diff --git a/SOURCES/0004-Don-t-leak-our-socket-s-fd-when-determining-network-.patch b/SOURCES/0004-Don-t-leak-our-socket-s-fd-when-determining-network-.patch deleted file mode 100644 index 25ee6c4..0000000 --- a/SOURCES/0004-Don-t-leak-our-socket-s-fd-when-determining-network-.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 7bb264df83a5e1f6182bb73594a058c1d3b7dc29 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 15:32:59 -0400 -Subject: [PATCH 04/31] Don't leak our socket's fd when determining network - info. - -Covscan again. - -Signed-off-by: Peter Jones ---- - src/lib/efi.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/src/lib/efi.c b/src/lib/efi.c -index 6b25dfe..8ba0e54 100644 ---- a/src/lib/efi.c -+++ b/src/lib/efi.c -@@ -631,13 +631,16 @@ make_net_load_option(char *iface, uint8_t *buf, size_t size) - err = ioctl(fd, SIOCETHTOOL, &ifr); - if (err < 0) { - perror("Cannot get driver information"); -+ close(fd); - return -1; - } - - if (strncmp(drvinfo.bus_info, "virtio", 6) == 0) { - err = get_virt_pci(drvinfo.bus_info, &bus, &slot, &func); -- if (err < 0) -+ if (err < 0) { -+ close(fd); - return err; -+ } - } else { - /* The domain part was added in 2.6 kernels. - * Test for that first. */ -@@ -648,6 +651,7 @@ make_net_load_option(char *iface, uint8_t *buf, size_t size) - &bus, &slot, &func); - if (err != 3) { - perror("Couldn't parse device location string."); -+ close(fd); - return -1; - } - } -@@ -655,9 +659,11 @@ make_net_load_option(char *iface, uint8_t *buf, size_t size) - - err = ioctl(fd, SIOCGIFHWADDR, &ifr); - if (err < 0) { -+ close(fd); - perror("Cannot get hardware address."); - return -1; - } -+ close(fd); - - buf_offset = 0; - needed = make_acpi_device_path(opts.acpi_hid, opts.acpi_uid, buf, --- -2.7.4 - diff --git a/SOURCES/0005-Fix-another-leaked-fd.patch b/SOURCES/0005-Fix-another-leaked-fd.patch deleted file mode 100644 index faf20b2..0000000 --- a/SOURCES/0005-Fix-another-leaked-fd.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 705c87aab92e20a8f71207895167632f0539e1fc Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 15:34:12 -0400 -Subject: [PATCH 05/31] Fix another leaked fd. - -Covscan some more. - -Signed-off-by: Peter Jones ---- - src/lib/efi.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/src/lib/efi.c b/src/lib/efi.c -index 8ba0e54..4218eb5 100644 ---- a/src/lib/efi.c -+++ b/src/lib/efi.c -@@ -528,8 +528,10 @@ make_disk_load_option(char *disk, uint8_t *buf, size_t size) - needed = make_edd10_device_path(opts.edd10_devicenum, - buf, size); - } -- if (needed < 0) -+ if (needed < 0) { -+ close(disk_fd); - return needed; -+ } - buf_offset += needed; - } - --- -2.7.4 - diff --git a/SOURCES/0006-Fix-some-minor-memory-leaks.patch b/SOURCES/0006-Fix-some-minor-memory-leaks.patch deleted file mode 100644 index f37706e..0000000 --- a/SOURCES/0006-Fix-some-minor-memory-leaks.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 239bd4013cd2909f5e0f9600be88f52b0248a032 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 15:40:29 -0400 -Subject: [PATCH 06/31] Fix some minor memory leaks. - -Well, one and not really another. Covscan is /almost/ a great tool. - -Signed-off-by: Peter Jones ---- - src/efibootmgr/efibootmgr.c | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index 5ca97ab..0a6ca5a 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -627,8 +627,11 @@ construct_boot_order(char *bootorder, int keep, - size_t data_size = 0; - - rc = parse_boot_order(bootorder, (uint16_t **)&data, &data_size); -- if (rc < 0 || data_size == 0) -+ if (rc < 0 || data_size == 0) { -+ if (data) /* this can't actually happen, but covscan believes */ -+ free(data); - return rc; -+ } - - if (!keep) { - *ret_data = data; -@@ -651,8 +654,11 @@ construct_boot_order(char *bootorder, int keep, - - size_t new_data_size = data_size + bo.data_size; - uint16_t *new_data = calloc(1, new_data_size); -- if (!new_data) -+ if (!new_data) { -+ if (data) -+ free(data); - return -1; -+ } - - memcpy(new_data, data, data_size); - memcpy(new_data + (data_size / sizeof (*new_data)), bo.data, --- -2.7.4 - diff --git a/SOURCES/0007-Make-sure-data-created-for-load-options-is-freed.patch b/SOURCES/0007-Make-sure-data-created-for-load-options-is-freed.patch deleted file mode 100644 index 06959f1..0000000 --- a/SOURCES/0007-Make-sure-data-created-for-load-options-is-freed.patch +++ /dev/null @@ -1,50 +0,0 @@ -From e0b5d2be5c1eee242b347c257c950fcaa952c0b3 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 15:46:04 -0400 -Subject: [PATCH 07/31] Make sure data created for load options is freed. - -Covscan... may not be right about this one. But it's better to be sure. - -Signed-off-by: Peter Jones ---- - src/lib/efi.c | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/src/lib/efi.c b/src/lib/efi.c -index 4218eb5..7dc3c92 100644 ---- a/src/lib/efi.c -+++ b/src/lib/efi.c -@@ -939,6 +939,7 @@ append_extra_args(uint8_t **data, size_t *data_size) - free(new_data); - if (ret < 0) - return -1; -+ new_data = NULL; - new_data_size = 0; - } - -@@ -946,15 +947,21 @@ append_extra_args(uint8_t **data, size_t *data_size) - ret = append_extra_args_unicode(&new_data, &new_data_size); - else - ret = append_extra_args_ascii(&new_data, &new_data_size); -- if (ret < 0) -+ if (ret < 0) { -+ if (new_data) /* this can't happen, but covscan believes */ -+ free(new_data); - return -1; -+ } - if (new_data_size) { - ret = add_new_data(data, data_size, new_data, new_data_size); - free(new_data); -+ new_data = NULL; - if (ret < 0) - return -1; - new_data_size = 0; - } - -+ if (new_data) /* once again, this can't happen, but covscan believes */ -+ free(new_data); - return 0; - } --- -2.7.4 - diff --git a/SOURCES/0008-Fix-an-error-path-not-checking-the-return-right-in-m.patch b/SOURCES/0008-Fix-an-error-path-not-checking-the-return-right-in-m.patch deleted file mode 100644 index db9defa..0000000 --- a/SOURCES/0008-Fix-an-error-path-not-checking-the-return-right-in-m.patch +++ /dev/null @@ -1,49 +0,0 @@ -From efc08df165e7209e79d68b25017a970c4b6c0504 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 15:47:57 -0400 -Subject: [PATCH 08/31] Fix an error path not checking the return right in - make_linux_load_option - -Covscan once again. - -Signed-off-by: Peter Jones ---- - src/lib/efi.c | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) - -diff --git a/src/lib/efi.c b/src/lib/efi.c -index 7dc3c92..a131abe 100644 ---- a/src/lib/efi.c -+++ b/src/lib/efi.c -@@ -722,7 +722,7 @@ make_linux_load_option(uint8_t **data, size_t *data_size) - size_t load_option_size = sizeof (*load_option); - efi_char16_t description[64]; - uint8_t *buf; -- size_t needed; -+ ssize_t needed; - off_t buf_offset = 0, desc_offset; - - load_option = calloc(1, sizeof (*load_option)); -@@ -754,11 +754,19 @@ make_linux_load_option(uint8_t **data, size_t *data_size) - - if (opts.iface) { - needed = make_net_load_option(opts.iface, NULL, 0); -+ if (needed < 0) { -+ free(buf); -+ return needed; -+ } - buf = extend(load_option, load_option_size, needed); - make_net_load_option(opts.iface, buf + buf_offset, needed); - buf_offset += needed; - } else { - needed = make_disk_load_option(opts.iface, NULL, 0); -+ if (needed < 0) { -+ free(buf); -+ return needed; -+ } - buf = extend(load_option, load_option_size, needed); - make_disk_load_option(opts.iface, buf + buf_offset, needed); - buf_offset += needed; --- -2.7.4 - diff --git a/SOURCES/0009-Try-to-avoid-covscan-freaking-out-about-sscanf-with-.patch b/SOURCES/0009-Try-to-avoid-covscan-freaking-out-about-sscanf-with-.patch deleted file mode 100644 index 25f0260..0000000 --- a/SOURCES/0009-Try-to-avoid-covscan-freaking-out-about-sscanf-with-.patch +++ /dev/null @@ -1,59 +0,0 @@ -From ecc540afd9fde2361b10c31d62ff70f15ca7971a Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 15:57:26 -0400 -Subject: [PATCH 09/31] Try to avoid covscan freaking out about sscanf with %n. -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -covscan says: - - 5. efibootmgr-0.8.0/src/lib/disk.c:96:tainted_data_argument – Calling - function "fgets(char * restrict, int, FILE * restrict)" taints argument - "line". - 10. efibootmgr-0.8.0/src/lib/disk.c:103:vararg_transitive – Call to - "sscanf(char const * restrict, char const * restrict, ...)" with - tainted argument "line" taints "major". - 11. efibootmgr-0.8.0/src/lib/disk.c:103:vararg_transitive – Call to - "sscanf(char const * restrict, char const * restrict, ...)" with - tainted argument "line" taints "scanned". - 13. efibootmgr-0.8.0/src/lib/disk.c:103:tainted_data – Using tainted - variable "scanned" as an index into an array "line". - -I *think* that's really complaining that if sscanf fails before -processing %n, then "scanned" is indeterminate here. So I've assigned -it to 0. - -Either way, if any of that goes wrong, the code's going to completely -fail. - -Signed-off-by: Peter Jones ---- - src/lib/disk.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/lib/disk.c b/src/lib/disk.c -index 904010b..4536a67 100644 ---- a/src/lib/disk.c -+++ b/src/lib/disk.c -@@ -56,7 +56,7 @@ get_virtblk_major(void) - } - while (fgets(line, sizeof line, f) != NULL) { - size_t len = strlen(line); -- int major, scanned; -+ int major, scanned = 0; - - if (len == 0 || line[len - 1] != '\n') { - break; -@@ -95,7 +95,7 @@ get_nvme_major(void) - } - while (fgets(line, sizeof line, f) != NULL) { - size_t len = strlen(line); -- int major, scanned; -+ int major, scanned = 0; - - if (len == 0 || line[len - 1] != '\n') { - break; --- -2.7.4 - diff --git a/SOURCES/0010-Get-rid-of-an-invalid-comparison.patch b/SOURCES/0010-Get-rid-of-an-invalid-comparison.patch deleted file mode 100644 index 1cf63ad..0000000 --- a/SOURCES/0010-Get-rid-of-an-invalid-comparison.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 3294351e275e01821673be29c972600737e2c5ae Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 16:02:58 -0400 -Subject: [PATCH 10/31] Get rid of an invalid comparison. - -Covscan. - -Signed-off-by: Peter Jones ---- - src/efibootmgr/efibootmgr.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index 0a6ca5a..d37227c 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -1008,7 +1008,7 @@ parse_opts(int argc, char **argv) - break; - case 'b': - rc = sscanf(optarg, "%X", &num); -- if (rc == 1 && num >= 0 && num < 0xffff) { -+ if (rc == 1 && num < 0xffff) { - opts.bootnum = num; - } else { - fprintf (stderr,"invalid hex value %s\n",optarg); --- -2.7.4 - diff --git a/SOURCES/0011-Covscan-can-t-tell-that-we-re-not-filling-a-buffer.patch b/SOURCES/0011-Covscan-can-t-tell-that-we-re-not-filling-a-buffer.patch deleted file mode 100644 index d56b2c0..0000000 --- a/SOURCES/0011-Covscan-can-t-tell-that-we-re-not-filling-a-buffer.patch +++ /dev/null @@ -1,41 +0,0 @@ -From c6bd43ebb2c7d7a8ef66b3cfc3804ad1ee18ac65 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 16:07:02 -0400 -Subject: [PATCH 11/31] Covscan can't tell that we're not filling a buffer... - -Because the pattern here is: - -rc = func_call(buf, buflen) -if (rc < 0) - return error; -buflen = rc; -buf = calloc(1, buflen) -if (!buf) - return error; -rc = func_call(buf, buflen); - -Covscan thinks the first func_call() might actually be doing something -to buf. It isn't, but that's not obvious. So make it NULL and 0 -instead of buf and buflen on the first call. - -Signed-off-by: Peter Jones ---- - src/efibootmgr/efibootmgr.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index d37227c..4ffb90e 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -772,7 +772,7 @@ show_boot_vars() - continue; - } - -- rc = unparse_raw_text(text_path, text_path_len, -+ rc = unparse_raw_text(NULL, 0, - ((uint8_t *)path) - + load_option->file_path_list_length, - optional_data_len); --- -2.7.4 - diff --git a/SOURCES/0012-Don-t-free-something-that-shouldn-t-ever-be-non-NULL.patch b/SOURCES/0012-Don-t-free-something-that-shouldn-t-ever-be-non-NULL.patch deleted file mode 100644 index b5a5450..0000000 --- a/SOURCES/0012-Don-t-free-something-that-shouldn-t-ever-be-non-NULL.patch +++ /dev/null @@ -1,57 +0,0 @@ -From e7626f7aa1e5947f8235728fed5af862b27a719e Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 16:15:27 -0400 -Subject: [PATCH 12/31] Don't free something that shouldn't ever be non-NULL. - -Instead, check and error if it's non-NULL. - -(Covscan, which got this completely wrong.) - -Signed-off-by: Peter Jones ---- - src/lib/efi.c | 8 ++------ - 1 file changed, 2 insertions(+), 6 deletions(-) - -diff --git a/src/lib/efi.c b/src/lib/efi.c -index a131abe..f604a1a 100644 ---- a/src/lib/efi.c -+++ b/src/lib/efi.c -@@ -792,7 +792,7 @@ append_extra_args_ascii(uint8_t **data, size_t *data_size) - int i; - unsigned long usedchars=0; - -- if (!data) -+ if (!data || *data) - return -1; - - for (i=opts.optind; i < opts.argc; i++) { -@@ -816,8 +816,6 @@ append_extra_args_ascii(uint8_t **data, size_t *data_size) - if (!new_data) - return 0; - -- if (*data) -- free(*data); - *data = (uint8_t *)new_data; - *data_size = usedchars; - -@@ -831,7 +829,7 @@ append_extra_args_unicode(uint8_t **data, size_t *data_size) - int i; - unsigned long usedchars=0; - -- if (!data) -+ if (!data || *data) - return -1; - - for (i = opts.optind; i < opts.argc; i++) { -@@ -857,8 +855,6 @@ append_extra_args_unicode(uint8_t **data, size_t *data_size) - if (!new_data) - return 0; - -- if (*data) -- free(*data); - *data = (uint8_t *)new_data; - *data_size = usedchars * sizeof (*new_data); - --- -2.7.4 - diff --git a/SOURCES/0013-Don-t-reuse-a-pointer-to-static-data-and-free-condit.patch b/SOURCES/0013-Don-t-reuse-a-pointer-to-static-data-and-free-condit.patch deleted file mode 100644 index 33f60c3..0000000 --- a/SOURCES/0013-Don-t-reuse-a-pointer-to-static-data-and-free-condit.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 7c9c04485631119423e94cdb207c22c3cd633323 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 16:20:04 -0400 -Subject: [PATCH 13/31] Don't reuse a pointer to static data and free - conditionally. - -Instead, use a second pointer and free that, because poor covscan can't -figure out what's going on. - -Signed-off-by: Peter Jones ---- - src/lib/unparse_path.c | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -diff --git a/src/lib/unparse_path.c b/src/lib/unparse_path.c -index 431dc06..5a69fde 100644 ---- a/src/lib/unparse_path.c -+++ b/src/lib/unparse_path.c -@@ -325,6 +325,7 @@ unparse_media_hard_drive_path(char *buffer, size_t buffer_size, - char text_uuid[40], *sig=text_uuid; - char a[16], b[16], c[16]; - int rc = 0; -+ char *sig_allocated = NULL; - - switch (hd->signature_type) { - case 0x00: -@@ -339,9 +340,11 @@ unparse_media_hard_drive_path(char *buffer, size_t buffer_size, - return -1; - break; - case 0x02: /* GPT */ -- rc = efi_guid_to_str((efi_guid_t *)hd->signature, &sig); -+ rc = efi_guid_to_str((efi_guid_t *)hd->signature, -+ &sig_allocated); - if (rc < 0) - return rc; -+ sig = sig_allocated; - break; - default: - return 0; -@@ -352,8 +355,8 @@ unparse_media_hard_drive_path(char *buffer, size_t buffer_size, - get(b, hd->start), - get(c, hd->size), - sig); -- if (hd->signature_type == 0x02) -- free(sig); -+ if (sig_allocated) -+ free(sig_allocated); - return rc; - } - --- -2.7.4 - diff --git a/SOURCES/0014-Handle-the-case-where-there-are-no-EFI-variables.patch b/SOURCES/0014-Handle-the-case-where-there-are-no-EFI-variables.patch deleted file mode 100644 index 65bc718..0000000 --- a/SOURCES/0014-Handle-the-case-where-there-are-no-EFI-variables.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 45305bebdf4bdc2bb6022b4788d034f5593bf19c Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 16:22:21 -0400 -Subject: [PATCH 14/31] Handle the case where there are no EFI variables. - -So we're on an EFI machine with no variables, eh covscan? - -Signed-off-by: Peter Jones ---- - src/lib/efi.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/lib/efi.c b/src/lib/efi.c -index f604a1a..7cdc884 100644 ---- a/src/lib/efi.c -+++ b/src/lib/efi.c -@@ -112,7 +112,7 @@ read_var_names(filter_t filter, char ***namelist) - - newlist = tmp; - } -- if (rc == 0) { -+ if (rc == 0 && newlist) { - qsort(newlist, nentries, sizeof (char *), cmpstringp); - *namelist = newlist; - } else { --- -2.7.4 - diff --git a/SOURCES/0015-Make-a-free-non-conditional-since-the-condition-can-.patch b/SOURCES/0015-Make-a-free-non-conditional-since-the-condition-can-.patch deleted file mode 100644 index 798e5ea..0000000 --- a/SOURCES/0015-Make-a-free-non-conditional-since-the-condition-can-.patch +++ /dev/null @@ -1,30 +0,0 @@ -From b18de3f385e732861de7425a20c77376813a554e Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 16:24:03 -0400 -Subject: [PATCH 15/31] Make a free non-conditional since the condition can't - be ture. - -Covscan again. I wonder if it'll complain about this. - -Signed-off-by: Peter Jones ---- - src/efibootmgr/efibootmgr.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index 4ffb90e..d73c6aa 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -463,8 +463,7 @@ read_boot_u16(const char *name) - } - - rc = data[0]; -- if (data != NULL) -- free(data); -+ free(data); - return rc; - } - --- -2.7.4 - diff --git a/SOURCES/0016-Check-malloc-return.patch b/SOURCES/0016-Check-malloc-return.patch deleted file mode 100644 index 36a942b..0000000 --- a/SOURCES/0016-Check-malloc-return.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 739d79c8e87dfaf9695f1f1f92e9ef45a2e706ff Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 16:49:51 -0400 -Subject: [PATCH 16/31] Check malloc() return. - -Covscan. - -Signed-off-by: Peter Jones ---- - src/efibootmgr/efibootmgr.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index d73c6aa..4d80f87 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -330,6 +330,8 @@ add_to_boot_order(uint16_t num) - old_data = (uint16_t *)boot_order->data; - new_data_size = boot_order->data_size + sizeof(uint16_t); - new_data = malloc(new_data_size); -+ if (!new_data) -+ return -1; - - new_data[0] = num; - memcpy(new_data+1, old_data, boot_order->data_size); --- -2.7.4 - diff --git a/SOURCES/0017-Check-open-s-return-correctly.patch b/SOURCES/0017-Check-open-s-return-correctly.patch deleted file mode 100644 index 845709c..0000000 --- a/SOURCES/0017-Check-open-s-return-correctly.patch +++ /dev/null @@ -1,28 +0,0 @@ -From f8a8d5d0a20ca118397e82ed81cf3b0ce492d8f4 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 16:50:08 -0400 -Subject: [PATCH 17/31] Check open()s return correctly. - -Covscan. - -Signed-off-by: Peter Jones ---- - src/lib/disk.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/lib/disk.c b/src/lib/disk.c -index 4536a67..337909e 100644 ---- a/src/lib/disk.c -+++ b/src/lib/disk.c -@@ -328,7 +328,7 @@ disk_get_ide_pci(int fd, - sprintf(procname, "/proc/ide/ide%d/config", info.controllernum); - - procfd = open(procname, O_RDONLY); -- if (!procfd) { -+ if (procfd < 0) { - perror("opening /proc/ide/ide*/config"); - return 1; - } --- -2.7.4 - diff --git a/SOURCES/0018-Check-lseek-for-errors.patch b/SOURCES/0018-Check-lseek-for-errors.patch deleted file mode 100644 index 40edbe7..0000000 --- a/SOURCES/0018-Check-lseek-for-errors.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 818be6eb0946100a38bd8a10634940e058fc4c90 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 16:56:49 -0400 -Subject: [PATCH 18/31] Check lseek() for errors. - -Covscan. - -Signed-off-by: Peter Jones ---- - src/lib/gpt.c | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/src/lib/gpt.c b/src/lib/gpt.c -index 67a8c41..fc2acf3 100644 ---- a/src/lib/gpt.c -+++ b/src/lib/gpt.c -@@ -221,6 +221,7 @@ read_lba(int fd, uint64_t lba, void *buffer, size_t bytes) - void *iobuf; - size_t iobuf_size; - int rc; -+ off_t new_offset; - - iobuf_size = lcm(bytes, sector_size); - rc = posix_memalign(&iobuf, sector_size, iobuf_size); -@@ -228,8 +229,11 @@ read_lba(int fd, uint64_t lba, void *buffer, size_t bytes) - return rc; - memset(iobuf, 0, bytes); - -- -- lseek(fd, offset, SEEK_SET); -+ new_offset = lseek(fd, offset, SEEK_SET); -+ if (new_offset == (off_t)-1) { -+ free(iobuf); -+ return 0; -+ } - bytesread = read(fd, iobuf, iobuf_size); - memcpy(buffer, iobuf, bytes); - free(iobuf); --- -2.7.4 - diff --git a/SOURCES/0019-Don-t-leak-our-partition-table-structures.patch b/SOURCES/0019-Don-t-leak-our-partition-table-structures.patch deleted file mode 100644 index b9292ae..0000000 --- a/SOURCES/0019-Don-t-leak-our-partition-table-structures.patch +++ /dev/null @@ -1,44 +0,0 @@ -From dd81884dfa1cd0c2ba97bcb3c0b04a69b14f9b6e Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 10 Sep 2014 17:03:23 -0400 -Subject: [PATCH 19/31] Don't leak our partition table structures. - -Covscan once more. - -Signed-off-by: Peter Jones ---- - src/lib/gpt.c | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) - -diff --git a/src/lib/gpt.c b/src/lib/gpt.c -index fc2acf3..8cb0e39 100644 ---- a/src/lib/gpt.c -+++ b/src/lib/gpt.c -@@ -612,6 +612,7 @@ gpt_disk_get_partition_info(int fd, - { - gpt_header *gpt = NULL; - gpt_entry *ptes = NULL, *p; -+ int rc = 0; - - if (!find_valid_gpt(fd, &gpt, &ptes)) - return 1; -@@ -628,9 +629,14 @@ gpt_disk_get_partition_info(int fd, - sizeof (p->unique_partition_guid)); - } else { - fprintf (stderr,"partition %d is not valid\n", num); -- return 1; -+ rc = 1; - } -- return 0; -+ if (ptes) -+ free(ptes); -+ if (gpt) -+ free(gpt); -+ -+ return rc; - } - - /* --- -2.7.4 - diff --git a/SOURCES/0020-Don-t-error-on-unset-BootOrder-when-we-re-trying-to-.patch b/SOURCES/0020-Don-t-error-on-unset-BootOrder-when-we-re-trying-to-.patch deleted file mode 100644 index a6bed75..0000000 --- a/SOURCES/0020-Don-t-error-on-unset-BootOrder-when-we-re-trying-to-.patch +++ /dev/null @@ -1,566 +0,0 @@ -From 1bc44d6c4fe0498f8ed2c52164f034ba483ccfb2 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 15 Oct 2014 10:35:56 -0400 -Subject: [PATCH 20/31] Don't error on unset BootOrder when we're trying to add - to or rm from it. - -Also print some better error messases here and there. - -Signed-off-by: Peter Jones ---- - README | 1 - - src/efibootmgr/efibootmgr.c | 126 +++++++++++++++++++++++++++----------------- - src/lib/efi.c | 95 +++++++++++++++++++-------------- - src/man/man8/efibootmgr.8 | 3 -- - 4 files changed, 131 insertions(+), 94 deletions(-) - -diff --git a/README b/README -index 3bc0a26..edbce4b 100644 ---- a/README -+++ b/README -@@ -29,7 +29,6 @@ usage: efibootmgr [options] - -O | --delete-bootorder delete BootOrder - -p | --part part (defaults to 1) containing loader - -q | --quiet be quiet -- --test filename don't write to NVRAM, write to filename - -t | --timeout seconds Boot manager timeout - -T | --delete-timeout delete Timeout value - -u | --unicode | --UCS-2 pass extra args as UCS-2 (default is ASCII) -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index 4d80f87..eb13942 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -33,6 +33,7 @@ - #define _GNU_SOURCE - - #include -+#include - #include - #include - #include -@@ -123,7 +124,7 @@ read_vars(char **namelist, - } - return; - err: -- fprintf(stderr, "efibootmgr: %m\n"); -+ warn("efibootmgr"); - exit(1); - } - -@@ -242,16 +243,20 @@ make_boot_var(list_t *boot_list) - free_number = opts.bootnum; - } - -- if (free_number == -1) -+ if (free_number == -1) { -+ warn("efibootmgr: no available boot variables"); - return NULL; -+ } - - /* Create a new efi_variable_t object - and populate it. - */ - - boot = calloc(1, sizeof(*boot)); -- if (!boot) -+ if (!boot) { -+ warn("efibootmgr"); - return NULL; -+ } - if (make_linux_load_option(&boot->data, &boot->data_size) < 0) - goto err_boot_entry; - if (append_extra_args(&boot->data, &boot->data_size) < 0) -@@ -260,8 +265,10 @@ make_boot_var(list_t *boot_list) - boot->num = free_number; - boot->guid = EFI_GLOBAL_VARIABLE; - rc = asprintf(&boot->name, "Boot%04X", free_number); -- if (rc < 0) -+ if (rc < 0) { -+ warn("efibootmgr"); - goto err_boot_entry; -+ } - boot->attributes = EFI_VARIABLE_NON_VOLATILE | - EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS; -@@ -272,8 +279,12 @@ make_boot_var(list_t *boot_list) - list_add_tail(&boot->list, boot_list); - return boot; - err_boot_entry: -- if (boot->name) -+ if (boot->name) { -+ warn("Could not set variable %s", boot->name); - free(boot->name); -+ } else { -+ warn("Could not set variable"); -+ } - if (boot->data) - free(boot->data); - free(boot); -@@ -313,6 +324,15 @@ read_boot_order(efi_variable_t **boot_order) - } - - static int -+set_boot_u16(const char *name, uint16_t num) -+{ -+ return efi_set_variable(EFI_GLOBAL_GUID, name, (uint8_t *)&num, -+ sizeof (num), EFI_VARIABLE_NON_VOLATILE | -+ EFI_VARIABLE_BOOTSERVICE_ACCESS | -+ EFI_VARIABLE_RUNTIME_ACCESS); -+} -+ -+static int - add_to_boot_order(uint16_t num) - { - efi_variable_t *boot_order = NULL; -@@ -321,8 +341,11 @@ add_to_boot_order(uint16_t num) - int rc; - - rc = read_boot_order(&boot_order); -- if (rc < 0) -+ if (rc < 0) { -+ if (errno == ENOENT) -+ rc = set_boot_u16("BootOrder", num); - return rc; -+ } - - /* We've now got an array (in boot_order->data) of the - * boot order. First add our entry, then copy the old array. -@@ -358,8 +381,11 @@ remove_dupes_from_boot_order(void) - int rc; - - rc = read_boot_order(&boot_order); -- if (rc < 0) -+ if (rc < 0) { -+ if (errno == ENOENT) -+ rc = 0; - return rc; -+ } - - old_data = (uint16_t *)(boot_order->data); - /* Start with the same size */ -@@ -409,8 +435,11 @@ remove_from_boot_order(uint16_t num) - int rc; - - rc = read_boot_order(&boot_order); -- if (rc < 0) -+ if (rc < 0) { -+ if (errno == ENOENT) -+ rc = 0; - return rc; -+ } - - /* We've now got an array (in boot_order->data) of the - boot order. Simply copy the array, skipping the -@@ -470,15 +499,6 @@ read_boot_u16(const char *name) - } - - static int --set_boot_u16(const char *name, uint16_t num) --{ -- return efi_set_variable(EFI_GLOBAL_GUID, name, (uint8_t *)&num, -- sizeof (num), EFI_VARIABLE_NON_VOLATILE | -- EFI_VARIABLE_BOOTSERVICE_ACCESS | -- EFI_VARIABLE_RUNTIME_ACCESS); --} -- --static int - delete_boot_var(uint16_t num) - { - int rc; -@@ -490,13 +510,18 @@ delete_boot_var(uint16_t num) - rc = efi_del_variable(EFI_GLOBAL_GUID, name); - - /* For backwards compatibility, try to delete abcdef entries as well */ -- if (rc < 0 && errno == ENOENT) { -- snprintf(name, sizeof(name), "Boot%04x", num); -- rc = efi_del_variable(EFI_GLOBAL_GUID, name); -+ if (rc < 0) { -+ if (errno == ENOENT) { -+ snprintf(name, sizeof(name), "Boot%04x", num); -+ rc = efi_del_variable(EFI_GLOBAL_GUID, name); -+ } else if (errno == EPERM) { -+ warn("Could not delete Boot%04X", num); -+ return rc; -+ } - } - - if (rc < 0) { -- fprintf(stderr,"\nboot entry: %X not found\n\n",num); -+ warnx("Boot entry %04X not found", num); - return rc; - } - list_for_each_safe(pos, n, &boot_entry_list) { -@@ -512,7 +537,6 @@ delete_boot_var(uint16_t num) - return 0; - } - -- - static void - set_var_nums(list_t *list) - { -@@ -1177,34 +1201,28 @@ main(int argc, char **argv) - if (opts.iface && ( - opts.acpi_hid < 0 || opts.acpi_uid < 0 || - opts.acpi_hid > UINT32_MAX || -- opts.acpi_uid > UINT32_MAX)) { -- fprintf(stderr, "\nYou must specify the ACPI HID and UID when using -i.\n\n"); -- return 1; -- } -+ opts.acpi_uid > UINT32_MAX)) -+ errx(1, "You must specify the ACPI HID and UID when using -i."); - -- if (!efi_variables_supported()) { -- fprintf(stderr, "\nEFI variables are not supported on this system.\n\n"); -- return 1; -- } -+ if (!efi_variables_supported()) -+ errx(2, "EFI variables are not supported on this system."); - - read_boot_var_names(&boot_names); - read_vars(boot_names, &boot_entry_list); - set_var_nums(&boot_entry_list); - - if (opts.delete_boot) { -- if (opts.bootnum == -1) { -- fprintf(stderr, "\nYou must specify a boot entry to delete (see the -b option).\n\n"); -- return 1; -- } -+ if (opts.bootnum == -1) -+ errx(3, "You must specify a boot entry to delete " -+ "(see the -b option)."); - else - ret = delete_boot_var(opts.bootnum); - } - - if (opts.active >= 0) { -- if (opts.bootnum == -1) { -- fprintf(stderr, "\nYou must specify a boot entry to activate (see the -b option).\n\n"); -- return 1; -- } -+ if (opts.bootnum == -1) -+ errx(4, "You must specify a boot entry to activate " -+ "(see the -b option"); - else - ret=set_active_state(); - } -@@ -1212,47 +1230,57 @@ main(int argc, char **argv) - if (opts.create) { - warn_duplicate_name(&boot_entry_list); - new_boot = make_boot_var(&boot_entry_list); -- if (!new_boot) { -- fprintf(stderr, "\nCould not prepare boot variable: %m\n\n"); -- return 1; -- } -+ if (!new_boot) -+ err(5, "Could not prepare boot variable"); - - /* Put this boot var in the right BootOrder */ - if (new_boot) - ret=add_to_boot_order(new_boot->num); -+ if (ret) -+ err(6, "Could not add entry to BootOrder"); - } - - if (opts.delete_bootorder) { - ret = efi_del_variable(EFI_GLOBAL_GUID, "BootOrder"); -+ err(7, "Could not remove entry from BootOrder"); - } - - if (opts.bootorder) { - ret = set_boot_order(opts.keep_old_entries); -+ if (ret) -+ err(8, "Could not set BootOrder"); - } - - if (opts.deduplicate) { - ret = remove_dupes_from_boot_order(); -+ if (ret) -+ err(9, "Could not set BootOrder"); - } - - if (opts.delete_bootnext) { - ret = efi_del_variable(EFI_GLOBAL_GUID, "BootNext"); -+ if (ret) -+ err(10, "Could not set BootNext"); - } - - if (opts.delete_timeout) { - ret = efi_del_variable(EFI_GLOBAL_GUID, "Timeout"); -+ if (ret) -+ err(11, "Could not delete Timeout"); - } - - if (opts.bootnext >= 0) { -- if (!is_current_boot_entry(opts.bootnext & 0xFFFF)){ -- fprintf (stderr,"\n\nboot entry %X does not exist\n\n", -- opts.bootnext); -- return 1; -- } -- ret=set_boot_u16("BootNext", opts.bootnext & 0xFFFF); -+ if (!is_current_boot_entry(opts.bootnext & 0xFFFF)) -+ errx(12, "Boot entry %X does not exist", opts.bootnext); -+ ret = set_boot_u16("BootNext", opts.bootnext & 0xFFFF); -+ if (ret) -+ err(13, "Could not set BootNext"); - } - - if (opts.set_timeout) { -- ret=set_boot_u16("Timeout", opts.timeout); -+ ret = set_boot_u16("Timeout", opts.timeout); -+ if (ret) -+ err(14, "Could not set Timeout"); - } - - if (!opts.quiet && ret == 0) { -diff --git a/src/lib/efi.c b/src/lib/efi.c -index 7cdc884..d19c00d 100644 ---- a/src/lib/efi.c -+++ b/src/lib/efi.c -@@ -19,6 +19,7 @@ - */ - - #include -+#include - #include - #include - #include -@@ -502,7 +503,6 @@ static ssize_t - make_disk_load_option(char *disk, uint8_t *buf, size_t size) - { - int disk_fd=0; -- char buffer[80]; - char signature[16]; - int rc, edd_version=0; - uint8_t mbr_type=0, signature_type=0; -@@ -514,11 +514,8 @@ make_disk_load_option(char *disk, uint8_t *buf, size_t size) - memset(signature, 0, sizeof(signature)); - - disk_fd = open(opts.disk, O_RDWR); -- if (disk_fd == -1) { -- sprintf(buffer, "Could not open disk %s", opts.disk); -- perror(buffer); -- return -1; -- } -+ if (disk_fd == -1) -+ err(5, "Could not open disk %s", opts.disk); - - if (opts.edd_version) { - edd_version = get_edd_version(); -@@ -539,12 +536,10 @@ make_disk_load_option(char *disk, uint8_t *buf, size_t size) - &part_start, &part_size, signature, - &mbr_type, &signature_type); - close(disk_fd); -- if (rc) { -- fprintf(stderr, "Error: no partition information on disk %s.\n" -- " Cowardly refusing to create a boot option.\n", -+ if (rc) -+ errx(5, "No partition information on disk %s.\n" -+ "Cowardly refusing to create a boot option.\n", - opts.disk); -- return -1; -- } - - needed = make_harddrive_device_path(opts.part, part_start, part_size, - (uint8_t *)signature, mbr_type, -@@ -724,10 +719,13 @@ make_linux_load_option(uint8_t **data, size_t *data_size) - uint8_t *buf; - ssize_t needed; - off_t buf_offset = 0, desc_offset; -+ int rc; - - load_option = calloc(1, sizeof (*load_option)); -- if (load_option == NULL) -+ if (load_option == NULL) { -+ fprintf(stderr, "efibootmgr: %m\n"); - return -1; -+ } - buf = (uint8_t *)load_option; - buf_offset = 0; - -@@ -755,21 +753,33 @@ make_linux_load_option(uint8_t **data, size_t *data_size) - if (opts.iface) { - needed = make_net_load_option(opts.iface, NULL, 0); - if (needed < 0) { -+ fprintf(stderr, "efibootmgr: could not create load option: %m\n"); - free(buf); - return needed; - } - buf = extend(load_option, load_option_size, needed); -- make_net_load_option(opts.iface, buf + buf_offset, needed); -+ rc = make_net_load_option(opts.iface, buf + buf_offset, needed); - buf_offset += needed; -+ if (rc < 0) { -+ fprintf(stderr, "efibootmgr: could not create load option: %m\n"); -+ free(buf); -+ return rc; -+ } - } else { - needed = make_disk_load_option(opts.iface, NULL, 0); - if (needed < 0) { -+ fprintf(stderr, "efibootmgr: could not create load option: %m\n"); - free(buf); - return needed; - } - buf = extend(load_option, load_option_size, needed); -- make_disk_load_option(opts.iface, buf + buf_offset, needed); -+ rc = make_disk_load_option(opts.iface, buf + buf_offset, needed); - buf_offset += needed; -+ if (rc < 0) { -+ fprintf(stderr, "efibootmgr: could not create load option: %m\n"); -+ free(buf); -+ return rc; -+ } - } - - load_option->file_path_list_length = buf_offset - desc_offset; -@@ -792,25 +802,25 @@ append_extra_args_ascii(uint8_t **data, size_t *data_size) - int i; - unsigned long usedchars=0; - -- if (!data || *data) -+ if (!data || *data) { -+ errno = EINVAL; - return -1; -+ } - - for (i=opts.optind; i < opts.argc; i++) { -- int l = strlen(opts.argv[i]) + 1; -+ int l = strlen(opts.argv[i]); - int space = (i < opts.argc - 1) ? 1: 0; -- uint8_t *tmp = realloc(new_data, (usedchars + l + space)); -+ uint8_t *tmp = realloc(new_data, (usedchars + l + space + 1)); - if (tmp == NULL) - return -1; - new_data = tmp; - p = (char *)new_data + usedchars; - strcpy(p, opts.argv[i]); - usedchars += l; -- p += l; - /* Put a space between args */ - if (space) -- p[usedchars++] = ' '; -- else -- p[usedchars] = '\0'; -+ new_data[usedchars++] = ' '; -+ new_data[usedchars] = '\0'; - } - - if (!new_data) -@@ -829,8 +839,10 @@ append_extra_args_unicode(uint8_t **data, size_t *data_size) - int i; - unsigned long usedchars=0; - -- if (!data || *data) -+ if (!data || *data) { -+ errno = EINVAL; - return -1; -+ } - - for (i = opts.optind; i < opts.argc; i++) { - int l = strlen(opts.argv[i]) + 1; -@@ -871,37 +883,31 @@ append_extra_args_file(uint8_t **data, size_t *data_size) - size_t maxchars = 0; - char *buffer; - -- if (!data) { -- fprintf(stderr, "internal error\n"); -- exit(1); -+ if (!data || *data) { -+ errno = EINVAL; -+ return -1; - } - - if (file && strncmp(file, "-", 1)) - fd = open(file, O_RDONLY); - -- if (fd == -1) { -- perror("Failed to open extra arguments file"); -- exit(1); -- } -+ if (fd < 0) -+ return -1; - - buffer = malloc(maxchars); - do { - if (maxchars - appended == 0) { - maxchars += 1024; - char *tmp = realloc(buffer, maxchars); -- if (tmp == NULL) { -- perror("Error reading extra arguments file"); -- exit(1); -- } -+ if (tmp == NULL) -+ return -1; - buffer = tmp; - } - num_read = read(fd, buffer + appended, maxchars - appended); -- if (num_read < 0) { -- perror("Error reading extra arguments file"); -- exit(1); -- } else if (num_read > 0) { -+ if (num_read < 0) -+ return -1; -+ else if (num_read > 0) - appended += num_read; -- } - } while (num_read > 0); - - if (fd != STDIN_FILENO) -@@ -935,14 +941,18 @@ append_extra_args(uint8_t **data, size_t *data_size) - - if (opts.extra_opts_file) { - ret = append_extra_args_file(&new_data, &new_data_size); -- if (ret < 0) -+ if (ret < 0) { -+ fprintf(stderr, "efibootmgr: append_extra_args: %m\n"); - return -1; -+ } - } - if (new_data_size) { - ret = add_new_data(data, data_size, new_data, new_data_size); - free(new_data); -- if (ret < 0) -+ if (ret < 0) { -+ fprintf(stderr, "efibootmgr: append_extra_args: %m\n"); - return -1; -+ } - new_data = NULL; - new_data_size = 0; - } -@@ -952,6 +962,7 @@ append_extra_args(uint8_t **data, size_t *data_size) - else - ret = append_extra_args_ascii(&new_data, &new_data_size); - if (ret < 0) { -+ fprintf(stderr, "efibootmgr: append_extra_args: %m\n"); - if (new_data) /* this can't happen, but covscan believes */ - free(new_data); - return -1; -@@ -960,8 +971,10 @@ append_extra_args(uint8_t **data, size_t *data_size) - ret = add_new_data(data, data_size, new_data, new_data_size); - free(new_data); - new_data = NULL; -- if (ret < 0) -+ if (ret < 0) { -+ fprintf(stderr, "efibootmgr: append_extra_args: %m\n"); - return -1; -+ } - new_data_size = 0; - } - -diff --git a/src/man/man8/efibootmgr.8 b/src/man/man8/efibootmgr.8 -index 96071d7..423bc16 100644 ---- a/src/man/man8/efibootmgr.8 -+++ b/src/man/man8/efibootmgr.8 -@@ -93,9 +93,6 @@ Partition number containing the bootloader (defaults to 1) - \fB-q | --quiet\fR - Quiet mode - supresses output. - .TP --\fB--test \fIfilename\fB\fR --Don't write to NVRAM, write to \fIfilename\fR\&. --.TP - \fB-t | --timeout \fIseconds\fB\fR - Boot Manager timeout, in \fIseconds\fR\&. - .TP --- -2.7.4 - diff --git a/SOURCES/0021-Fix-buffer-overflow-when-remove_from_boot_order-remo.patch b/SOURCES/0021-Fix-buffer-overflow-when-remove_from_boot_order-remo.patch deleted file mode 100644 index 310631b..0000000 --- a/SOURCES/0021-Fix-buffer-overflow-when-remove_from_boot_order-remo.patch +++ /dev/null @@ -1,95 +0,0 @@ -From ba13b5a7ccb4141e9918caf1c0272a5d72c4da61 Mon Sep 17 00:00:00 2001 -From: Lenny Szubowicz -Date: Tue, 6 Jan 2015 11:17:01 -0500 -Subject: [PATCH 21/31] Fix buffer overflow when remove_from_boot_order removes - nothing - -Deleting a boot entry via "-b xxxx -B" also attempts to remove -that entry from boot order via a call to remove_from_boot_order. -Although unusual, it's possible that the entry being deleted is -not in boot order. Correct the handling of this case in -remove_from_boot_order, which malloc's space for the new boot -order list wrongly assuming that at least one entry will be -removed. However, if no entry is removed, then 2 bytes are -overwritten beyond the malloc'ed space. This can result in heap -corruption and possible termination via a SIGABRT if the -corruption is detected by the heap allocation routines. - -While there, simplify the routine to do the removal of boot -entries in place in the original data buffer, skip the -unnecessary BootOrder variable update if nothing got removed, -and free the malloc'ed boot_order struct on the way out. - -Resolves: RH BZ 1168019 - -Signed-off-by: Lenny Szubowicz ---- - src/efibootmgr/efibootmgr.c | 33 +++++++++++++++------------------ - 1 file changed, 15 insertions(+), 18 deletions(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index eb13942..1b55125 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -429,8 +429,7 @@ static int - remove_from_boot_order(uint16_t num) - { - efi_variable_t *boot_order = NULL; -- uint64_t new_data_size; -- uint16_t *new_data, *old_data; -+ uint16_t *data; - unsigned int old_i,new_i; - int rc; - -@@ -442,34 +441,32 @@ remove_from_boot_order(uint16_t num) - } - - /* We've now got an array (in boot_order->data) of the -- boot order. Simply copy the array, skipping the -- entry we're deleting. -+ boot order. Squeeze out any instance of the entry we're -+ deleting by shifting the remainder down. - */ -- old_data = (uint16_t *)(boot_order->data); -- /* Start with the same size */ -- new_data_size = boot_order->data_size - sizeof (*new_data); -- new_data = malloc(new_data_size); -- if (!new_data) -- return -1; -+ data = (uint16_t *)(boot_order->data); - - for (old_i=0,new_i=0; -- old_i < boot_order->data_size / sizeof(*new_data); -+ old_i < boot_order->data_size / sizeof(data[0]); - old_i++) { -- if (old_data[old_i] != num) { -- /* Copy this value */ -- new_data[new_i] = old_data[old_i]; -+ if (data[old_i] != num) { -+ if (new_i != old_i) -+ data[new_i] = data[old_i]; - new_i++; - } - } - -- /* Now new_data has what we need */ -- free(boot_order->data); -- boot_order->data = (uint8_t *)new_data; -- boot_order->data_size = new_data_size; -+ /* If nothing removed, no need to update the BootOrder variable */ -+ if (new_i == old_i) -+ goto all_done; -+ -+ /* BootOrder variable needs to be updated */ - efi_del_variable(EFI_GLOBAL_GUID, "BootOrder"); - rc = efi_set_variable(EFI_GLOBAL_GUID, "BootOrder", boot_order->data, - boot_order->data_size, boot_order->attributes); -+all_done: - free(boot_order->data); -+ free(boot_order); - return rc; - } - --- -2.7.4 - diff --git a/SOURCES/0022-Make-sure-BootOrder-gets-shortened-while-deleting.patch b/SOURCES/0022-Make-sure-BootOrder-gets-shortened-while-deleting.patch deleted file mode 100644 index b21dff3..0000000 --- a/SOURCES/0022-Make-sure-BootOrder-gets-shortened-while-deleting.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 2c20a1e3e209970c35322b4f282a717974de051a Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 2 Feb 2015 11:13:20 -0500 -Subject: [PATCH 22/31] Make sure BootOrder gets shortened while deleting. - -So, what has happened is that a chunk of the patch for 1168019 got -dropped in a merge conflict error, and as a result the variable is never -actually shortened, and some of the old data is set as a result. - -Resolves: rhbz#1188313 - -Signed-off-by: Peter Jones ---- - src/efibootmgr/efibootmgr.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index 1b55125..b5d4147 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -462,6 +462,11 @@ remove_from_boot_order(uint16_t num) - - /* BootOrder variable needs to be updated */ - efi_del_variable(EFI_GLOBAL_GUID, "BootOrder"); -+ -+ if (new_i == 0) -+ goto all_done; -+ -+ boot_order->data_size = sizeof(data[0]) * new_i; - rc = efi_set_variable(EFI_GLOBAL_GUID, "BootOrder", boot_order->data, - boot_order->data_size, boot_order->attributes); - all_done: --- -2.7.4 - diff --git a/SOURCES/0023-Make-o-s-behavior-actually-match-the-documented-beha.patch b/SOURCES/0023-Make-o-s-behavior-actually-match-the-documented-beha.patch deleted file mode 100644 index 99dc576..0000000 --- a/SOURCES/0023-Make-o-s-behavior-actually-match-the-documented-beha.patch +++ /dev/null @@ -1,153 +0,0 @@ -From 50296303d8066a327c17cbd10c55a02e0b69b6ba Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 20 Oct 2014 12:04:34 -0400 -Subject: [PATCH 23/31] Make -o's behavior actually match the documented - behavior. - -Also make it a bit better and reporting errors. - -This should actually resolve -https://github.com/vathpela/efibootmgr/issues/12 . - -Signed-off-by: Peter Jones ---- - src/efibootmgr/efibootmgr.c | 94 +++++++++++++++++++++++++++++++-------------- - 1 file changed, 66 insertions(+), 28 deletions(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index b5d4147..ec083af 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -34,10 +34,11 @@ - - #include - #include -+#include -+#include - #include - #include - #include --#include - #include - #include - #include -@@ -596,52 +597,89 @@ is_current_boot_entry(int b) - return 0; - } - -+static void -+print_error_arrow(char *message, char *buffer, off_t offset) -+{ -+ unsigned int i; -+ fprintf(stderr, "%s: %s\n", message, buffer); -+ for (i = 0; i < strlen(message) + 2; i++) -+ fprintf(stderr, " "); -+ for (i = 0; i < offset; i++) -+ fprintf(stderr, " "); -+ fprintf(stderr, "^\n"); -+} - - static int - parse_boot_order(char *buffer, uint16_t **order, size_t *length) - { -- int i, len; -- int num, rc; -- - uint16_t *data; - size_t data_size; -- -- len = strlen(buffer); -- if (len % 5 != 4) { -- fprintf(stderr, "\nInvalid boot order: %s\n\n", buffer); -- return -1; -+ size_t len = strlen(buffer); -+ intptr_t end = (intptr_t)buffer + len + 1; -+ -+ int num = 0; -+ char *buf = buffer; -+ while ((intptr_t)buf < end) { -+ size_t comma = strcspn(buf, ","); -+ if (comma == 0) { -+ off_t offset = (intptr_t)buf - (intptr_t)buffer; -+ print_error_arrow("Malformed boot order",buffer,offset); -+ exit(8); -+ } else { -+ num++; -+ } -+ buf += comma + 1; - } -- len = (len / 5) + 1; - -- data_size = len * sizeof (*data); -- data = malloc(data_size); -+ data = calloc(num, sizeof (*data)); - if (!data) - return -1; -- -- for (i=0; i < len && *buffer; i++) { -- rc = sscanf(buffer, "%x", &num); -- if (rc == 1) { -- data[i] = num & 0xFFFF; -- } else { -- fprintf(stderr,"\nInvalid hex characters in boot order: %s\n\n",buffer); -+ data_size = num * sizeof (*data); -+ -+ int i = 0; -+ buf = buffer; -+ while ((intptr_t)buf < end) { -+ unsigned long result = 0; -+ size_t comma = strcspn(buf, ","); -+ -+ buf[comma] = '\0'; -+ char *endptr = NULL; -+ result = strtoul(buf, &endptr, 16); -+ if ((result == ULONG_MAX && errno == ERANGE) || -+ (endptr && *endptr != '\0')) { -+ print_error_arrow("Invalid boot order", buffer, -+ (intptr_t)endptr - (intptr_t)buffer); - free(data); -- return -1; -+ exit(8); - } -+ if (result > 0xffff) { -+ fprintf(stderr, "Invalid boot order entry value: %lX\n", -+ result); -+ print_error_arrow("Invalid boot order", buffer, -+ (intptr_t)buf - (intptr_t)buffer); -+ free(data); -+ exit(8); -+ } -+ - /* make sure this is an existing boot entry */ -- if (!is_current_boot_entry(data[i])) { -- fprintf (stderr,"\nboot entry %X does not exist\n\n",data[i]); -+ if (!is_current_boot_entry(result)) { -+ print_error_arrow("Invalid boot order entry value", -+ buffer, -+ (intptr_t)buf - (intptr_t)buffer); -+ fprintf(stderr,"Boot entry %04lX does not exist\n", -+ result); - free(data); -- return -1; -+ exit(8); - } - -- /* Advance to the comma */ -- while (*buffer && *buffer != ',') buffer++; -- /* Advance through the comma(s) */ -- while (*buffer && *buffer == ',') buffer++; -+ data[i++] = result; -+ buf[comma] = ','; -+ buf += comma + 1; - } -+ - *order = data; - *length = data_size; -- return i; -+ return num; - } - - static int --- -2.7.4 - diff --git a/SOURCES/0024-Make-all-the-other-places-we-re-parsing-XXXX-also-do.patch b/SOURCES/0024-Make-all-the-other-places-we-re-parsing-XXXX-also-do.patch deleted file mode 100644 index 32e5d4f..0000000 --- a/SOURCES/0024-Make-all-the-other-places-we-re-parsing-XXXX-also-do.patch +++ /dev/null @@ -1,154 +0,0 @@ -From e827a434324261ebc4e539060379aeba4ba98b0b Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 20 Oct 2014 12:15:26 -0400 -Subject: [PATCH 24/31] Make all the other places we're parsing XXXX also do a - better job. - -This is related to https://github.com/vathpela/efibootmgr/issues/12 . - -Signed-off-by: Peter Jones ---- - src/efibootmgr/efibootmgr.c | 94 +++++++++++++++++++++++++++++++++++---------- - 1 file changed, 73 insertions(+), 21 deletions(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index ec083af..015bf65 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -1071,15 +1071,26 @@ parse_opts(int argc, char **argv) - case 'B': - opts.delete_boot = 1; - break; -- case 'b': -- rc = sscanf(optarg, "%X", &num); -- if (rc == 1 && num < 0xffff) { -- opts.bootnum = num; -- } else { -- fprintf (stderr,"invalid hex value %s\n",optarg); -+ case 'b': { -+ char *endptr = NULL; -+ unsigned long result; -+ result = strtoul(optarg, &endptr, 16); -+ if ((result == ULONG_MAX && errno == ERANGE) || -+ (endptr && *endptr != '\0')) { -+ print_error_arrow("Invalid bootnum value", -+ optarg, -+ (intptr_t)endptr - (intptr_t)optarg); -+ exit(1); -+ } -+ if (result > 0xffff) { -+ fprintf(stderr, "Invalid bootnum value: %lX\n", -+ result); - exit(1); - } -+ -+ opts.bootnum = num; - break; -+ } - case 'c': - opts.create = 1; - break; -@@ -1114,14 +1125,26 @@ parse_opts(int argc, char **argv) - exit(0); - break; - -- case 'H': -- rc = sscanf(optarg, "%x", &num); -- if (rc == 1) opts.acpi_hid = num; -- else { -- fprintf (stderr,"invalid hex value %s\n",optarg); -+ case 'H': { -+ char *endptr = NULL; -+ unsigned long result; -+ result = strtoul(optarg, &endptr, 16); -+ if ((result == ULONG_MAX && errno == ERANGE) || -+ (endptr && *endptr != '\0')) { -+ print_error_arrow("Invalid ACPI_HID value", -+ optarg, -+ (intptr_t)endptr - (intptr_t)optarg); -+ exit(1); -+ } -+ if (result > 0xffff) { -+ fprintf(stderr, "Invalid ACPI_HID value: %lX\n", -+ result); - exit(1); - } -+ -+ opts.acpi_hid = num; - break; -+ } - case 'i': - opts.iface = optarg; - break; -@@ -1137,14 +1160,31 @@ parse_opts(int argc, char **argv) - case 'N': - opts.delete_bootnext = 1; - break; -- case 'n': -- rc = sscanf(optarg, "%x", &num); -- if (rc == 1) opts.bootnext = num; -- else { -- fprintf (stderr,"invalid hex value %s\n",optarg); -+ case 'n': { -+ char *endptr = NULL; -+ unsigned long result; -+ result = strtoul(optarg, &endptr, 16); -+ if ((result == ULONG_MAX && errno == ERANGE) || -+ (endptr && *endptr != '\0')) { -+ print_error_arrow("Invalid BootNext value", -+ optarg, -+ (intptr_t)endptr - (intptr_t)optarg); -+ exit(1); -+ } -+ if (result > 0xffff) { -+ fprintf(stderr, "Invalid BootNext value: %lX\n", -+ result); - exit(1); - } -+ if (!is_current_boot_entry(result)) { -+ fprintf(stderr, -+ "Boot entry %04lX does not exist\n", -+ result); -+ exit(1); -+ } -+ opts.bootnext = result; - break; -+ } - case 'o': - opts.bootorder = optarg; - break; -@@ -1180,14 +1220,26 @@ parse_opts(int argc, char **argv) - opts.unicode = 1; - break; - -- case 'U': -- rc = sscanf(optarg, "%x", &num); -- if (rc == 1) opts.acpi_uid = num; -- else { -- fprintf (stderr,"invalid hex value %s\n",optarg); -+ case 'U': { -+ char *endptr = NULL; -+ unsigned long result; -+ result = strtoul(optarg, &endptr, 16); -+ if ((result == ULONG_MAX && errno == ERANGE) || -+ (endptr && *endptr != '\0')) { -+ print_error_arrow("Invalid ACPI_UID value", -+ optarg, -+ (intptr_t)endptr - (intptr_t)optarg); -+ exit(1); -+ } -+ if (result > 0xffff) { -+ fprintf(stderr, "Invalid ACPI_UID value: %lX\n", -+ result); - exit(1); - } -+ -+ opts.acpi_uid = num; - break; -+ } - case 'v': - opts.verbose = 1; - if (optarg) { --- -2.7.4 - diff --git a/SOURCES/0025-Set-guid-when-reading-boot-entries-in-read_vars.patch b/SOURCES/0025-Set-guid-when-reading-boot-entries-in-read_vars.patch deleted file mode 100644 index 36eb34f..0000000 --- a/SOURCES/0025-Set-guid-when-reading-boot-entries-in-read_vars.patch +++ /dev/null @@ -1,25 +0,0 @@ -From c9599e12e736f4c4f09ca28e36f032a580c9bac9 Mon Sep 17 00:00:00 2001 -From: Alexis Murzeau -Date: Sat, 18 Apr 2015 23:03:23 +0200 -Subject: [PATCH 25/31] Set guid when reading boot entries in read_vars. - -set_active_state use boot->guid, so set it to EFI_GLOBAL_GUID. ---- - src/efibootmgr/efibootmgr.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index 015bf65..b4417c8 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -120,6 +120,7 @@ read_vars(char **namelist, - entry->attributes = entry->attributes & ~(1 << 31); - - entry->name = namelist[i]; -+ entry->guid = EFI_GLOBAL_GUID; - list_add_tail(&entry->list, head); - } - } --- -2.7.4 - diff --git a/SOURCES/0026-Don-t-check-for-bootnext-existing-until-we-ve-read-t.patch b/SOURCES/0026-Don-t-check-for-bootnext-existing-until-we-ve-read-t.patch deleted file mode 100644 index 2c2390d..0000000 --- a/SOURCES/0026-Don-t-check-for-bootnext-existing-until-we-ve-read-t.patch +++ /dev/null @@ -1,33 +0,0 @@ -From b6270d161ce2b5543ae679c893f3c0d8df0f67c9 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 9 Jul 2015 13:06:42 -0400 -Subject: [PATCH 26/31] Don't check for bootnext existing until we've read the - variables. - -Resolves: rhbz#1241411 - -Signed-off-by: root ---- - src/efibootmgr/efibootmgr.c | 6 ------ - 1 file changed, 6 deletions(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index b4417c8..4fe0448 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -1177,12 +1177,6 @@ parse_opts(int argc, char **argv) - result); - exit(1); - } -- if (!is_current_boot_entry(result)) { -- fprintf(stderr, -- "Boot entry %04lX does not exist\n", -- result); -- exit(1); -- } - opts.bootnext = result; - break; - } --- -2.7.4 - diff --git a/SOURCES/0027-Actually-set-the-values-we-re-using-to-the-results-o.patch b/SOURCES/0027-Actually-set-the-values-we-re-using-to-the-results-o.patch deleted file mode 100644 index 745d998..0000000 --- a/SOURCES/0027-Actually-set-the-values-we-re-using-to-the-results-o.patch +++ /dev/null @@ -1,47 +0,0 @@ -From bca20371ba27d3c1db0e4d2d1ec533971ccac18f Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 21 Oct 2014 16:02:13 -0400 -Subject: [PATCH 27/31] Actually /set/ the values we're using to the results of - parsing the number. - -This should fix https://github.com/vathpela/efibootmgr/issues/18 - -Signed-off-by: Peter Jones ---- - src/efibootmgr/efibootmgr.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index 4fe0448..73faffa 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -1089,7 +1089,7 @@ parse_opts(int argc, char **argv) - exit(1); - } - -- opts.bootnum = num; -+ opts.bootnum = result; - break; - } - case 'c': -@@ -1143,7 +1143,7 @@ parse_opts(int argc, char **argv) - exit(1); - } - -- opts.acpi_hid = num; -+ opts.acpi_hid = result; - break; - } - case 'i': -@@ -1232,7 +1232,7 @@ parse_opts(int argc, char **argv) - exit(1); - } - -- opts.acpi_uid = num; -+ opts.acpi_uid = result; - break; - } - case 'v': --- -2.7.4 - diff --git a/SOURCES/0028-Add-m-and-M-options-to-support-address-range-mirror.patch b/SOURCES/0028-Add-m-and-M-options-to-support-address-range-mirror.patch deleted file mode 100644 index acf2a60..0000000 --- a/SOURCES/0028-Add-m-and-M-options-to-support-address-range-mirror.patch +++ /dev/null @@ -1,287 +0,0 @@ -From 745b6244b2b81d7698520646089657ff9f121da2 Mon Sep 17 00:00:00 2001 -From: "Luck, Tony" -Date: Tue, 9 Jun 2015 10:14:58 -0700 -Subject: [PATCH 28/31] Add -m and -M options to support address range mirror - -BIOS and OS pass messages for address range mirror using a pair of -UEFI variables: - - MirrorCurrent: Written by BIOS to tell the OS that the platform supports - address range mirror and to say whether mirroring was set up using - the desired parameters - MirrorRequest: Written by OS to tell BIOS new paramters to use on next boot - -This is documented in the RAS validation guide for memory address range -mirroring for the Xeon E7-v3 family: - - https://software.intel.com/sites/default/files/managed/43/6a/Memory%20Address%20Range%20Mirroring%20Validation%20Guide.pdf - -Signed-off-by: Tony Luck ---- - src/efibootmgr/efibootmgr.c | 143 +++++++++++++++++++++++++++++++++++++++++++- - src/include/efi.h | 15 +++++ - src/include/efibootmgr.h | 5 ++ - 3 files changed, 162 insertions(+), 1 deletion(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index 73faffa..7cb87fa 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -948,8 +948,114 @@ set_active_state() - return -1; - } - -+static int -+get_mirror(int which, int *below4g, int *above4g, int *mirrorstatus) -+{ -+ int rc; -+ uint8_t *data; -+ ADDRESS_RANGE_MIRROR_VARIABLE_DATA *abm; -+ size_t data_size; -+ uint32_t attributes; -+ char *name; - -+ if (which) -+ name = ADDRESS_RANGE_MIRROR_VARIABLE_REQUEST; -+ else -+ name = ADDRESS_RANGE_MIRROR_VARIABLE_CURRENT; -+ -+ rc = efi_get_variable(ADDRESS_RANGE_MIRROR_VARIABLE_GUID, name, -+ &data, &data_size, &attributes); -+ if (rc == 0) { -+ abm = (ADDRESS_RANGE_MIRROR_VARIABLE_DATA *)data; -+ if (!which && abm->mirror_version != MIRROR_VERSION) { -+ fprintf(stderr, "** Warning ** : unrecognised version for memory mirror i/f\n"); -+ return 2; -+ } -+ *below4g = abm->mirror_memory_below_4gb; -+ *above4g = abm->mirror_amount_above_4gb; -+ *mirrorstatus = abm->mirror_status; -+ } -+ return rc; -+} - -+static int -+set_mirror(int below4g, int above4g) -+{ -+ int s, status, rc; -+ uint8_t *data; -+ ADDRESS_RANGE_MIRROR_VARIABLE_DATA abm; -+ size_t data_size; -+ uint32_t attributes; -+ int oldbelow4g, oldabove4g; -+ -+ if ((s = get_mirror(0, &oldbelow4g, &oldabove4g, &status)) == 0) { -+ if (oldbelow4g == below4g && oldabove4g == above4g) -+ return 0; -+ } else { -+ fprintf(stderr, "** Warning ** : platform does not support memory mirror\n"); -+ return s; -+ } -+ -+ data = (uint8_t *)&abm; -+ data_size = sizeof (abm); -+ attributes = EFI_VARIABLE_NON_VOLATILE -+ | EFI_VARIABLE_BOOTSERVICE_ACCESS -+ | EFI_VARIABLE_RUNTIME_ACCESS; -+ -+ abm.mirror_version = MIRROR_VERSION; -+ abm.mirror_amount_above_4gb = opts.set_mirror_hi ? above4g : oldabove4g; -+ abm.mirror_memory_below_4gb = opts.set_mirror_lo ? below4g : oldbelow4g; -+ abm.mirror_status = 0; -+ data = (uint8_t *)&abm; -+ rc = efi_set_variable(ADDRESS_RANGE_MIRROR_VARIABLE_GUID, -+ ADDRESS_RANGE_MIRROR_VARIABLE_REQUEST, data, -+ data_size, attributes); -+ return rc; -+} -+ -+static void -+show_mirror(void) -+{ -+ int status; -+ int below4g, above4g; -+ int rbelow4g, rabove4g; -+ -+ if (get_mirror(0, &below4g, &above4g, &status) == 0) { -+ if (status == 0) { -+ printf("MirroredPercentageAbove4G: %d.%.2d\n", above4g/100, above4g%100); -+ printf("MirrorMemoryBelow4GB: %s\n", below4g ? "true" : "false"); -+ } else { -+ printf("MirrorStatus: "); -+ switch (status) { -+ case 1: -+ printf("Platform does not support address range mirror\n"); -+ break; -+ case 2: -+ printf("Invalid version number\n"); -+ break; -+ case 3: -+ printf("MirroredMemoryAbove4GB > 50.00%%\n"); -+ break; -+ case 4: -+ printf("DIMM configuration does not allow mirror\n"); -+ break; -+ case 5: -+ printf("OEM specific method\n"); -+ break; -+ default: -+ printf("%u\n", status); -+ break; -+ } -+ printf("DesiredMirroredPercentageAbove4G: %d.%.2d\n", above4g/100, above4g%100); -+ printf("DesiredMirrorMemoryBelow4GB: %s\n", below4g ? "true" : "false"); -+ } -+ } -+ if ((get_mirror(1, &rbelow4g, &rabove4g, &status) == 0) && -+ (above4g != rabove4g || below4g != rbelow4g)) { -+ printf("RequestMirroredPercentageAbove4G: %d.%.2d\n", rabove4g/100, rabove4g%100); -+ printf("RequestMirrorMemoryBelow4GB: %s\n", rbelow4g ? "true" : "false"); -+ } -+} - - static void - usage() -@@ -970,6 +1076,8 @@ usage() - printf("\t-i | --iface name create a netboot entry for the named interface\n"); - printf("\t-l | --loader name (defaults to \\EFI\\redhat\\shim.efi)\n"); - printf("\t-L | --label label Boot manager display label (defaults to \"Linux\")\n"); -+ printf("\t-m | --mirror-below-4G t|f mirror memory below 4GB\n"); -+ printf("\t-M | --mirror-above-4G X percentage memory to mirror above 4GB\n"); - printf("\t-n | --bootnext XXXX set BootNext to XXXX (hex)\n"); - printf("\t-N | --delete-bootnext delete BootNext\n"); - printf("\t-o | --bootorder XXXX,YYYY,ZZZZ,... explicitly set BootOrder (hex)\n"); -@@ -1010,6 +1118,7 @@ parse_opts(int argc, char **argv) - { - int c, rc; - unsigned int num; -+ float fnum; - int option_index = 0; - - while (1) -@@ -1032,6 +1141,8 @@ parse_opts(int argc, char **argv) - {"keep", no_argument, 0, 'k'}, - {"loader", required_argument, 0, 'l'}, - {"label", required_argument, 0, 'L'}, -+ {"mirror-below-4G", required_argument, 0, 'm'}, -+ {"mirror-above-4G", required_argument, 0, 'M'}, - {"bootnext", required_argument, 0, 'n'}, - {"delete-bootnext", no_argument, 0, 'N'}, - {"bootorder", required_argument, 0, 'o'}, -@@ -1052,7 +1163,7 @@ parse_opts(int argc, char **argv) - }; - - c = getopt_long (argc, argv, -- "AaBb:cDd:e:E:gH:i:l:L:n:No:Op:qt:TuU:v::Vw" -+ "AaBb:cDd:e:E:gH:i:l:L:M:m:n:No:Op:qt:TuU:v::Vw" - "@:h", - long_options, &option_index); - if (c == -1) -@@ -1158,6 +1269,31 @@ parse_opts(int argc, char **argv) - case 'L': - opts.label = optarg; - break; -+ case 'm': -+ opts.set_mirror_lo = 1; -+ switch (optarg[0]) { -+ case '1': case 'y': case 't': -+ opts.below4g = 1; -+ break; -+ case '0': case 'n': case 'f': -+ opts.below4g = 0; -+ break; -+ default: -+ fprintf (stderr,"invalid boolean value %s\n",optarg); -+ exit(1); -+ } -+ break; -+ case 'M': -+ opts.set_mirror_hi = 1; -+ rc = sscanf(optarg, "%f", &fnum); -+ if (rc == 1 && fnum <= 50) { -+ opts.above4g = fnum * 100; /* percent to basis points */ -+ } -+ else { -+ fprintf (stderr,"invalid numeric value %s\n",optarg); -+ exit(1); -+ } -+ break; - case 'N': - opts.delete_bootnext = 1; - break; -@@ -1370,6 +1506,10 @@ main(int argc, char **argv) - err(14, "Could not set Timeout"); - } - -+ if (opts.set_mirror_lo || opts.set_mirror_hi) { -+ ret=set_mirror(opts.below4g, opts.above4g); -+ } -+ - if (!opts.quiet && ret == 0) { - num = read_boot_u16("BootNext"); - if (num != -1 ) { -@@ -1385,6 +1525,7 @@ main(int argc, char **argv) - } - show_boot_order(); - show_boot_vars(); -+ show_mirror(); - } - free_vars(&boot_entry_list); - free_array(boot_names); -diff --git a/src/include/efi.h b/src/include/efi.h -index ec25be9..d95bf4e 100644 ---- a/src/include/efi.h -+++ b/src/include/efi.h -@@ -309,6 +309,9 @@ typedef struct { - /* Used for ACPI _HID */ - #define EISAID_PNP0A03 0xa0341d0 - -+#define ADDRESS_RANGE_MIRROR_VARIABLE_GUID \ -+EFI_GUID( 0x7b9be2e0, 0xe28a, 0x4197, 0xad3e, 0x32, 0xf0, 0x62, 0xf9, 0x46, 0x2c) -+ - /* Exported functions */ - - extern EFI_DEVICE_PATH *load_option_path(EFI_LOAD_OPTION *option); -@@ -318,4 +321,16 @@ extern ssize_t make_linux_load_option(uint8_t **data, size_t *data_size); - extern int append_extra_args(uint8_t **data, size_t *data_size); - - -+typedef struct { -+ uint8_t mirror_version; -+ uint8_t mirror_memory_below_4gb; -+ uint16_t mirror_amount_above_4gb; -+ uint8_t mirror_status; -+} __attribute__((packed)) ADDRESS_RANGE_MIRROR_VARIABLE_DATA; -+ -+#define MIRROR_VERSION 1 -+ -+#define ADDRESS_RANGE_MIRROR_VARIABLE_CURRENT "MirrorCurrent" -+#define ADDRESS_RANGE_MIRROR_VARIABLE_REQUEST "MirrorRequest" -+ - #endif /* EFI_H */ -diff --git a/src/include/efibootmgr.h b/src/include/efibootmgr.h -index b978caf..6196b75 100644 ---- a/src/include/efibootmgr.h -+++ b/src/include/efibootmgr.h -@@ -40,6 +40,8 @@ typedef struct { - int bootnext; - int verbose; - int active; -+ int below4g; -+ int above4g; - int deduplicate; - int64_t acpi_hid; - int64_t acpi_uid; -@@ -54,6 +56,9 @@ typedef struct { - unsigned int forcegpt:1; - unsigned int set_timeout:1; - unsigned int delete_timeout:1; -+ unsigned int set_mirror_lo:1; -+ unsigned int set_mirror_hi:1; -+ unsigned int no_boot_order:1; - unsigned short int timeout; - } efibootmgr_opt_t; - --- -2.7.4 - diff --git a/SOURCES/0029-Fix-insusufficient-validation-check-of-M-option.patch b/SOURCES/0029-Fix-insusufficient-validation-check-of-M-option.patch deleted file mode 100644 index 65be64d..0000000 --- a/SOURCES/0029-Fix-insusufficient-validation-check-of-M-option.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 701377c07bb7f8a72680d797f22ec30299789fe1 Mon Sep 17 00:00:00 2001 -From: Taku Izumi -Date: Tue, 26 Jan 2016 14:32:50 +0900 -Subject: [PATCH 29/31] Fix insusufficient validation check of -M option - -The acceptable range of -M (--mirror-above-4G) option should -be from 0 to 50. So the negative value should be rejected. -Otherwise unintended value can be specified. - -e.g. - - > efibootmgr -M -3 -... -MirroredPercentageAbove4G: 25.00 -MirrorMemoryBelow4GB: true -RequestMirroredPercentageAbove4G: 652.36 -RequestMirrorMemoryBelow4GB: true - - 652.36 is invalid value for MirroredPercentageAbove4G and should - not be specified. - -Signed-off-by: Taku Izumi ---- - src/efibootmgr/efibootmgr.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c -index 7cb87fa..ffecc55 100644 ---- a/src/efibootmgr/efibootmgr.c -+++ b/src/efibootmgr/efibootmgr.c -@@ -1286,7 +1286,7 @@ parse_opts(int argc, char **argv) - case 'M': - opts.set_mirror_hi = 1; - rc = sscanf(optarg, "%f", &fnum); -- if (rc == 1 && fnum <= 50) { -+ if (rc == 1 && fnum <= 50 && fnum >= 0) { - opts.above4g = fnum * 100; /* percent to basis points */ - } - else { --- -2.7.4 - diff --git a/SOURCES/0030-Add-lacking-description-of-man-for-m-and-M-option.patch b/SOURCES/0030-Add-lacking-description-of-man-for-m-and-M-option.patch deleted file mode 100644 index 1caa67a..0000000 --- a/SOURCES/0030-Add-lacking-description-of-man-for-m-and-M-option.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 21fb50cf0432aded5475aa2cecc2058043d00d35 Mon Sep 17 00:00:00 2001 -From: Taku Izumi -Date: Fri, 11 Mar 2016 11:45:27 +0900 -Subject: [PATCH 30/31] Add lacking description of man for -m and -M option - -Currently there's no description of efibootmgr man page -for -m and -M option. - -This patch adds the lacking description for -m and -M -option. - -Signed-off-by: Taku Izumi ---- - src/man/man8/efibootmgr.8 | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/src/man/man8/efibootmgr.8 b/src/man/man8/efibootmgr.8 -index 423bc16..8f67038 100644 ---- a/src/man/man8/efibootmgr.8 -+++ b/src/man/man8/efibootmgr.8 -@@ -9,7 +9,7 @@ - efibootmgr \- manipulate the EFI Boot Manager - .SH SYNOPSIS - --\fBefibootmgr\fR [ \fB-a\fR ] [ \fB-A\fR ] [ \fB-b \fIXXXX\fB\fR ] [ \fB-B \fIXXXX\fB\fR ] [ \fB-c\fR ] [ \fB-d \fIDISK\fB\fR ] [ \fB-D\fR ] [ \fB-e \fI1|3|-1\fB\fR ] [ \fB-E \fINUM\fB\fR ] [ \fB-g\fR ] [ \fB-H \fIXXXX\fB\fR ] [ \fB-i \fINAME\fB\fR ] [ \fB-l \fINAME\fB\fR ] [ \fB-L \fILABEL\fB\fR ] [ \fB-n \fIXXXX\fB\fR ] [ \fB-N\fR ] [ \fB-o \fIXXXX\fB,\fIYYYY\fB,\fIZZZZ\fB\fR\fI ...\fR ] [ \fB-O\fR ] [ \fB-p \fIPART\fB\fR ] [ \fB-q\fR ] [ \fB-t \fIseconds\fB\fR ] [ \fB-T\fR ] [ \fB-u\fR ] [ \fB-U \fIXXXX\fB\fR ] [ \fB-v\fR ] [ \fB-V\fR ] [ \fB-w\fR ] [ \fB-@ \fIfile\fB\fR ] -+\fBefibootmgr\fR [ \fB-a\fR ] [ \fB-A\fR ] [ \fB-b \fIXXXX\fB\fR ] [ \fB-B \fIXXXX\fB\fR ] [ \fB-c\fR ] [ \fB-d \fIDISK\fB\fR ] [ \fB-D\fR ] [ \fB-e \fI1|3|-1\fB\fR ] [ \fB-E \fINUM\fB\fR ] [ \fB-g\fR ] [ \fB-H \fIXXXX\fB\fR ] [ \fB-i \fINAME\fB\fR ] [ \fB-l \fINAME\fB\fR ] [ \fB-L \fILABEL\fB\fR ] [ \fB-m \fIt|f\fB\fR ] [ \fB-M \fIX\fB\fR ] [ \fB-n \fIXXXX\fB\fR ] [ \fB-N\fR ] [ \fB-o \fIXXXX\fB,\fIYYYY\fB,\fIZZZZ\fB\fR\fI ...\fR ] [ \fB-O\fR ] [ \fB-p \fIPART\fB\fR ] [ \fB-q\fR ] [ \fB-t \fIseconds\fB\fR ] [ \fB-T\fR ] [ \fB-u\fR ] [ \fB-U \fIXXXX\fB\fR ] [ \fB-v\fR ] [ \fB-V\fR ] [ \fB-w\fR ] [ \fB-@ \fIfile\fB\fR ] - - .SH "DESCRIPTION" - .PP -@@ -75,6 +75,12 @@ Specify a loader (defaults to \fI\\\\elilo.efi\fR) - \fB-L | --label \fILABEL\fB\fR - Boot manager display label (defaults to "Linux") - .TP -+\fB-m | --mirror-below-4G \fIt|f\fB\fR -+Set t if you want to mirror memory below 4GB -+.TP -+\fB-M | --mirror-above-4G \fIX\fB\fR -+X percentage memory to mirror above 4GB. Floating-point value with up to 2 decimal places is accepted. -+.TP - \fB-n | --bootnext \fIXXXX\fB\fR - Set BootNext to XXXX (hex) - .TP --- -2.7.4 - diff --git a/SOURCES/0031-Manually-define-NVME_IOCTL_ID.patch b/SOURCES/0031-Manually-define-NVME_IOCTL_ID.patch deleted file mode 100644 index d8e4cff..0000000 --- a/SOURCES/0031-Manually-define-NVME_IOCTL_ID.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 1bec5911f25f9d7990cd1c92c1376a2aa36fbd20 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 6 Jun 2016 15:18:57 -0400 -Subject: [PATCH 31/31] Manually define NVME_IOCTL_ID. - -The kernel has changed and the include file isn't at the same place -between various arches. Since we just need the ID, defined it instead -of worrying about where it's from. - -Related: rhbz#1271412 - -Signed-off-by: Peter Jones ---- - src/lib/scsi_ioctls.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/src/lib/scsi_ioctls.c b/src/lib/scsi_ioctls.c -index 3aaa933..2e0b5b4 100644 ---- a/src/lib/scsi_ioctls.c -+++ b/src/lib/scsi_ioctls.c -@@ -24,9 +24,12 @@ - #include - #include - #include --#include - #include "scsi_ioctls.h" - -+#ifndef NVME_IOCTL_ID -+#define NVME_IOCTL_ID _IO('N', 0x40) -+#endif -+ - int - get_nvme_ns_id(int fd, uint32_t *ns_id) - { --- -2.7.4 - diff --git a/SOURCES/0032-efibootmgr.8-Fix-typos-grammar-for-mirroring-options.patch b/SOURCES/0032-efibootmgr.8-Fix-typos-grammar-for-mirroring-options.patch deleted file mode 100644 index aec4246..0000000 --- a/SOURCES/0032-efibootmgr.8-Fix-typos-grammar-for-mirroring-options.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 8e60748c3b69b5dc4ca70beb3da9b684643829f0 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 13 Jul 2016 14:24:34 -0400 -Subject: [PATCH] efibootmgr.8: Fix typos/grammar for mirroring options - -Signed-off-by: Peter Jones ---- - src/efibootmgr.8 | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/src/efibootmgr.8 b/src/efibootmgr.8 -index b335335..755d5c1 100644 ---- a/src/man/man8/efibootmgr.8 -+++ b/src/man/man8/efibootmgr.8 -@@ -73,10 +73,11 @@ Specify a loader (defaults to \fI\\\\elilo.efi\fR) - Boot manager display label (defaults to "Linux") - .TP - \fB-m | --mirror-below-4G \fIt|f\fB\fR --Set t if you want to mirror memory below 4GB -+Configure the system to mirror memory below 4GB - .TP - \fB-M | --mirror-above-4G \fIX\fB\fR --X percentage memory to mirror above 4GB. Floating-point value with up to 2 decimal places is accepted. -+Configure the system to mirror X percent of memory above 4GB. Floating-point -+value with up to 2 decimal places is accepted. - .TP - \fB-n | --bootnext \fIXXXX\fB\fR - Set BootNext to XXXX (hex) --- -2.7.4 - diff --git a/SPECS/efibootmgr.spec b/SPECS/efibootmgr.spec index 7682a6d..55a6c5b 100644 --- a/SPECS/efibootmgr.spec +++ b/SPECS/efibootmgr.spec @@ -1,12 +1,15 @@ +%define efivar_version 31-1 + Summary: EFI Boot Manager Name: efibootmgr -Version: 0.8.0 -Release: 10%{?dist} +Version: 15 +Release: 2%{?dist} Group: System Environment/Base License: GPLv2+ -URL: http://github.com/vathpela/%{name}/ -BuildRequires: pciutils-devel, zlib-devel, git -BuildRequires: efivar-libs, efivar-devel +URL: http://github.com/rhinstaller/%{name}/ +BuildRequires: git, popt-devel +BuildRequires: efivar-libs >= %{efivar_version} +BuildRequires: efivar-devel >= %{efivar_version} BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXXXX) # EFI/UEFI don't exist on PPC ExclusiveArch: x86_64 aarch64 @@ -15,39 +18,12 @@ ExclusiveArch: x86_64 aarch64 Conflicts: elilo <= 3.6-6 Obsoletes: elilo <= 3.6-6 -Source0: https://github.com/vathpela/%{name}/releases/download/%{name}-%{version}/%{name}-%{version}.tar.bz2 -Patch0001: 0001-Make-EFI-redhat-shim.efi-the-default-bootloader.patch -Patch0002: 0002-Fix-a-bad-allocation-size.patch -Patch0003: 0003-Make-the-return-path-something-coverity-can-actually.patch -Patch0004: 0004-Don-t-leak-our-socket-s-fd-when-determining-network-.patch -Patch0005: 0005-Fix-another-leaked-fd.patch -Patch0006: 0006-Fix-some-minor-memory-leaks.patch -Patch0007: 0007-Make-sure-data-created-for-load-options-is-freed.patch -Patch0008: 0008-Fix-an-error-path-not-checking-the-return-right-in-m.patch -Patch0009: 0009-Try-to-avoid-covscan-freaking-out-about-sscanf-with-.patch -Patch0010: 0010-Get-rid-of-an-invalid-comparison.patch -Patch0011: 0011-Covscan-can-t-tell-that-we-re-not-filling-a-buffer.patch -Patch0012: 0012-Don-t-free-something-that-shouldn-t-ever-be-non-NULL.patch -Patch0013: 0013-Don-t-reuse-a-pointer-to-static-data-and-free-condit.patch -Patch0014: 0014-Handle-the-case-where-there-are-no-EFI-variables.patch -Patch0015: 0015-Make-a-free-non-conditional-since-the-condition-can-.patch -Patch0016: 0016-Check-malloc-return.patch -Patch0017: 0017-Check-open-s-return-correctly.patch -Patch0018: 0018-Check-lseek-for-errors.patch -Patch0019: 0019-Don-t-leak-our-partition-table-structures.patch -Patch0020: 0020-Don-t-error-on-unset-BootOrder-when-we-re-trying-to-.patch -Patch0021: 0021-Fix-buffer-overflow-when-remove_from_boot_order-remo.patch -Patch0022: 0022-Make-sure-BootOrder-gets-shortened-while-deleting.patch -Patch0023: 0023-Make-o-s-behavior-actually-match-the-documented-beha.patch -Patch0024: 0024-Make-all-the-other-places-we-re-parsing-XXXX-also-do.patch -Patch0025: 0025-Set-guid-when-reading-boot-entries-in-read_vars.patch -Patch0026: 0026-Don-t-check-for-bootnext-existing-until-we-ve-read-t.patch -Patch0027: 0027-Actually-set-the-values-we-re-using-to-the-results-o.patch -Patch0028: 0028-Add-m-and-M-options-to-support-address-range-mirror.patch -Patch0029: 0029-Fix-insusufficient-validation-check-of-M-option.patch -Patch0030: 0030-Add-lacking-description-of-man-for-m-and-M-option.patch -Patch0031: 0031-Manually-define-NVME_IOCTL_ID.patch -Patch0032: 0032-efibootmgr.8-Fix-typos-grammar-for-mirroring-options.patch +Source0: https://github.com/rhinstaller/%{name}/releases/download/%{name}-%{version}/%{name}-%{version}.tar.bz2 +Patch0001: 0001-RHEL-7.x-popt-doesn-t-have-popt.pc-work-around-its-a.patch +Patch0002: 0002-Don-t-build-efibootdump-on-RHEL-7.4.patch +Patch0003: 0003-make_linux_load_option-check-data_size-correctly.patch + +%global efidir %(eval echo $(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/')) %description %{name} displays and allows the user to edit the Intel Extensible @@ -67,26 +43,35 @@ git config --unset user.email git config --unset user.name %build -make %{?_smp_mflags} EXTRA_CFLAGS='%{optflags}' +make %{?_smp_mflags} EXTRA_CFLAGS='%{optflags}' EFIDIR=%{efidir} %install rm -rf %{buildroot} -mkdir -p %{buildroot}%{_sbindir} %{buildroot}%{_mandir}/man8 -install -p --mode 755 src/%{name}/%{name} %{buildroot}%{_sbindir} -gzip -9 -c src/man/man8/%{name}.8 > src/man/man8/%{name}.8.gz -touch -r src/man/man8/%{name}.8 src/man/man8/%{name}.8.gz -install -p --mode 644 src/man/man8/%{name}.8.gz %{buildroot}%{_mandir}/man8 +%make_install EFIDIR=%{efidir} libdir=%{_libdir} \ + bindir=%{_bindir} mandir=%{_mandir} localedir=%{_datadir}/locale/ \ + includedir=%{_includedir} libexecdir=%{_libexecdir} \ + datadir=%{_datadir} %clean rm -rf %{buildroot} %files %defattr(-,root,root,-) -%{_sbindir}/%{name} -%{_mandir}/man8/%{name}.8.gz -%doc README INSTALL COPYING +%{!?_licensedir:%global license %%doc} +%license COPYING +%{_sbindir}/* +%{_mandir}/*/*.?.gz +%doc README %changelog +* Tue May 09 2017 Peter Jones - 15-2 +- Fix some coverity issues + Related: rhbz#1380825 + +* Mon Mar 13 2017 Peter Jones - 15-1 +- Update to efivar 15 for fwupdate + Related: rhbz#1380825 + * Tue Jul 19 2016 Peter Jones - 0.8.0-10 - Another man page update for Memory Address Range Mirroring Related: rhbz#1271412