From c9eda15717fb5e4743bc1c1285c9aa035fbabf3c Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 19 2015 16:08:09 +0000 Subject: import efibootmgr-0.8.0-7.el7 --- diff --git a/SOURCES/0001-Actually-set-the-values-we-re-using-to-the-results-o.patch b/SOURCES/0001-Actually-set-the-values-we-re-using-to-the-results-o.patch new file mode 100644 index 0000000..1c52dcb --- /dev/null +++ b/SOURCES/0001-Actually-set-the-values-we-re-using-to-the-results-o.patch @@ -0,0 +1,47 @@ +From 70030c8fb08ae523204170cf3cc5918c0f6ba4a7 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 21 Oct 2014 16:02:13 -0400 +Subject: [PATCH] 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 546b55c..85dc73e 100644 +--- a/src/efibootmgr/efibootmgr.c ++++ b/src/efibootmgr/efibootmgr.c +@@ -1086,7 +1086,7 @@ parse_opts(int argc, char **argv) + exit(1); + } + +- opts.bootnum = num; ++ opts.bootnum = result; + break; + } + case 'c': +@@ -1140,7 +1140,7 @@ parse_opts(int argc, char **argv) + exit(1); + } + +- opts.acpi_hid = num; ++ opts.acpi_hid = result; + break; + } + case 'i': +@@ -1229,7 +1229,7 @@ parse_opts(int argc, char **argv) + exit(1); + } + +- opts.acpi_uid = num; ++ opts.acpi_uid = result; + break; + } + case 'v': +-- +2.4.3 + diff --git a/SOURCES/0001-Don-t-check-for-bootnext-existing-until-we-ve-read-t.patch b/SOURCES/0001-Don-t-check-for-bootnext-existing-until-we-ve-read-t.patch new file mode 100644 index 0000000..10031b6 --- /dev/null +++ b/SOURCES/0001-Don-t-check-for-bootnext-existing-until-we-ve-read-t.patch @@ -0,0 +1,33 @@ +From 7178a860614979e16ba9895aee46654574de7485 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 9 Jul 2015 13:06:42 -0400 +Subject: [PATCH] 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; + } +-- +1.8.3.1 + diff --git a/SOURCES/0001-Make-o-s-behavior-actually-match-the-documented-beha.patch b/SOURCES/0001-Make-o-s-behavior-actually-match-the-documented-beha.patch new file mode 100644 index 0000000..664e777 --- /dev/null +++ b/SOURCES/0001-Make-o-s-behavior-actually-match-the-documented-beha.patch @@ -0,0 +1,153 @@ +From 8c725c629f2ead41532c4b908e9c713187a7f564 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 20 Oct 2014 12:04:34 -0400 +Subject: [PATCH 1/2] 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 6e5a4c0..f819b96 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 +@@ -594,52 +595,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.4.3 + diff --git a/SOURCES/0001-Set-guid-when-reading-boot-entries-in-read_vars.patch b/SOURCES/0001-Set-guid-when-reading-boot-entries-in-read_vars.patch new file mode 100644 index 0000000..43b60af --- /dev/null +++ b/SOURCES/0001-Set-guid-when-reading-boot-entries-in-read_vars.patch @@ -0,0 +1,25 @@ +From 272eeb462072976c58dbf2c3085e5a4c59576a15 Mon Sep 17 00:00:00 2001 +From: Alexis Murzeau +Date: Sat, 18 Apr 2015 23:03:23 +0200 +Subject: [PATCH] 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 4c682c1..ba25afa 100644 +--- a/src/efibootmgr/efibootmgr.c ++++ b/src/efibootmgr/efibootmgr.c +@@ -123,6 +123,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.4.3 + diff --git a/SOURCES/0002-Make-all-the-other-places-we-re-parsing-XXXX-also-do.patch b/SOURCES/0002-Make-all-the-other-places-we-re-parsing-XXXX-also-do.patch new file mode 100644 index 0000000..ea69005 --- /dev/null +++ b/SOURCES/0002-Make-all-the-other-places-we-re-parsing-XXXX-also-do.patch @@ -0,0 +1,154 @@ +From b857ce058d6f7fa3fa47c839bc86de243cd1fd4e Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 20 Oct 2014 12:15:26 -0400 +Subject: [PATCH 2/2] 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 f819b96..2b1ac47 100644 +--- a/src/efibootmgr/efibootmgr.c ++++ b/src/efibootmgr/efibootmgr.c +@@ -1069,15 +1069,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; +@@ -1112,14 +1123,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; +@@ -1135,14 +1158,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; +@@ -1178,14 +1218,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.4.3 + diff --git a/SPECS/efibootmgr.spec b/SPECS/efibootmgr.spec index ffbd90e..3b7c454 100644 --- a/SPECS/efibootmgr.spec +++ b/SPECS/efibootmgr.spec @@ -1,7 +1,7 @@ Summary: EFI Boot Manager Name: efibootmgr Version: 0.8.0 -Release: 5%{?dist} +Release: 7%{?dist} Group: System Environment/Base License: GPLv2+ URL: http://github.com/vathpela/%{name}/ @@ -38,6 +38,12 @@ Patch0018: 0018-Don-t-leak-our-partition-table-structures.patch Patch0019: 0001-Don-t-error-on-unset-BootOrder-when-we-re-trying-to-.patch Patch0020: 0001-Fix-buffer-overflow-when-remove_from_boot_order-remo.patch Patch0021: 0001-Make-sure-BootOrder-gets-shortened-while-deleting.patch +Patch0022: 0001-Make-o-s-behavior-actually-match-the-documented-beha.patch +Patch0023: 0002-Make-all-the-other-places-we-re-parsing-XXXX-also-do.patch +Patch0024: 0001-Set-guid-when-reading-boot-entries-in-read_vars.patch +Patch0025: 0001-Don-t-check-for-bootnext-existing-until-we-ve-read-t.patch +Patch0026: 0001-Actually-set-the-values-we-re-using-to-the-results-o.patch + %description %{name} displays and allows the user to edit the Intel Extensible @@ -77,6 +83,16 @@ rm -rf %{buildroot} %doc README INSTALL COPYING %changelog +* Thu Jul 09 2015 Peter Jones - 0.8.0-7 +- Fix a couple of problems parsing command line options QA is seeing. + Resolves: rhbz#1241411 + +* Tue Jun 30 2015 Peter Jones - 0.8.0-6 +- Handle -b and -o parsing in a way that matches the documentation. + Resolves: rhbz#1174964 +- Use the right GUID when setting boot entries active/inactive + Resolves: rhbz#1221771 + * Mon Feb 02 2015 Peter Jones - 0.8.0-5 - Fix patch merge error from -4 Resolves: rhbz#1188313