Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Feb 2023 00:48:38 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 82c0aea8f3c2 - stable/13 - efivar: Allow NULL paths in build_dp
Message-ID:  <202302190048.31J0mc77069600@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=82c0aea8f3c270c6d20b093cf711d4bb1472237c

commit 82c0aea8f3c270c6d20b093cf711d4bb1472237c
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-02-16 16:36:03 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-02-19 00:46:57 +0000

    efivar: Allow NULL paths in build_dp
    
    Allow there to be NULL paths in buildp. This lets us return the device
    path to the partition, as well as to files on the partition.
    
    Sponsored by:           Netflix
    Reviewed by:            corvink, manu, asomers
    Differential Revision:  https://reviews.freebsd.org/D38615
    
    (cherry picked from commit 49fd6affdbfe6af53f119ebb27ff5e5e292e1f67)
---
 lib/libefivar/efivar-dp-xlate.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/lib/libefivar/efivar-dp-xlate.c b/lib/libefivar/efivar-dp-xlate.c
index effc8a2de475..b6adae80fdb4 100644
--- a/lib/libefivar/efivar-dp-xlate.c
+++ b/lib/libefivar/efivar-dp-xlate.c
@@ -544,23 +544,25 @@ find_geom_efimedia(struct gmesh *mesh, const char *dev)
 static int
 build_dp(const char *efimedia, const char *relpath, efidp *dp)
 {
-	char *fp, *dptxt = NULL, *cp, *rp;
+	char *fp = NULL, *dptxt = NULL, *cp, *rp = NULL;
 	int rv = 0;
 	efidp out = NULL;
 	size_t len;
 
-	rp = strdup(relpath);
-	for (cp = rp; *cp; cp++)
-		if (*cp == '/')
-			*cp = '\\';
-	fp = path_to_file_dp(rp);
-	free(rp);
-	if (fp == NULL) {
-		rv = ENOMEM;
-		goto errout;
+	if (relpath != NULL) {
+		rp = strdup(relpath);
+		for (cp = rp; *cp; cp++)
+			if (*cp == '/')
+				*cp = '\\';
+		fp = path_to_file_dp(rp);
+		free(rp);
+		if (fp == NULL) {
+			rv = ENOMEM;
+			goto errout;
+		}
 	}
 
-	asprintf(&dptxt, "%s/%s", efimedia, fp);
+	asprintf(&dptxt, "%s/%s", efimedia, fp == NULL ? "" : fp);
 	out = malloc(8192);
 	len = efidp_parse_device_path(dptxt, out, 8192);
 	if (len > 8192) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302190048.31J0mc77069600>