git: c2d161d30006 - stable/13 - efivar: Attempt to fix setting/printing/deleting EFI vars with '-' in their name
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 02 Mar 2022 21:57:35 UTC
The branch stable/13 has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=c2d161d300064de86683443ba5020b9c0004efb3 commit c2d161d300064de86683443ba5020b9c0004efb3 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2021-04-09 22:35:17 +0000 Commit: Eric van Gyzen <vangyzen@FreeBSD.org> CommitDate: 2022-03-02 21:56:31 +0000 efivar: Attempt to fix setting/printing/deleting EFI vars with '-' in their name Due to how we're parsing UUIDs, we were disallowing setting, printing or deleting any UEFI variable with a '-' in it when you attempted to do that operation with the exact name (wildcard reporting was unaffected). Fix the parser to loop over all the dashes in the name and only give up when all possible matches are exhausted. Reviewed by: markj@ Sponsored by: Netflix, Inc Differential Revision: https://reviews.freebsd.org/D29620 (cherry picked from commit 0292a5c95f14b1ad3df39ee71c51cc830864a3aa) --- usr.sbin/efivar/efivar.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/usr.sbin/efivar/efivar.c b/usr.sbin/efivar/efivar.c index cbf4050a787d..2fdf0e4d09b8 100644 --- a/usr.sbin/efivar/efivar.c +++ b/usr.sbin/efivar/efivar.c @@ -118,15 +118,24 @@ rep_errx(int eval, const char *fmt, ...) static void breakdown_name(char *name, efi_guid_t *guid, char **vname) { - char *cp; - - cp = strrchr(name, '-'); - if (cp == NULL) - rep_errx(1, "Invalid name: %s", name); - *vname = cp + 1; - *cp = '\0'; - if (efi_name_to_guid(name, guid) < 0) - rep_errx(1, "Invalid guid %s", name); + char *cp, *ocp; + + ocp = NULL; + while (true) { + cp = strrchr(name, '-'); + if (cp == NULL) { + if (ocp != NULL) + *ocp = '-'; + rep_errx(1, "Invalid guid in: %s", name); + } + if (ocp != NULL) + *ocp = '-'; + *vname = cp + 1; + *cp = '\0'; + ocp = cp; + if (efi_name_to_guid(name, guid) >= 0) + break; + } } static uint8_t *