From owner-dev-commits-src-all@freebsd.org Fri Apr 9 22:38:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 354DC5C0D55; Fri, 9 Apr 2021 22:38:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHChw0QYsz4jmB; Fri, 9 Apr 2021 22:38:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F423025EFB; Fri, 9 Apr 2021 22:38:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 139McdDU019448; Fri, 9 Apr 2021 22:38:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 139McdWs019447; Fri, 9 Apr 2021 22:38:39 GMT (envelope-from git) Date: Fri, 9 Apr 2021 22:38:39 GMT Message-Id: <202104092238.139McdWs019447@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 0292a5c95f14 - main - efivar: Attempt to fix setting/printing/deleting EFI vars with '-' in their name MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0292a5c95f14b1ad3df39ee71c51cc830864a3aa Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 22:38:40 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=0292a5c95f14b1ad3df39ee71c51cc830864a3aa commit 0292a5c95f14b1ad3df39ee71c51cc830864a3aa Author: Warner Losh AuthorDate: 2021-04-09 22:35:17 +0000 Commit: Warner Losh CommitDate: 2021-04-09 22:36:40 +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 --- 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 *