From: Jan Kiszka <[email protected]>

We already generate to the path as EFI_DEVICE_PATH, we just need to
convert and dump that object. This not only simplifies the code, it also
ensures that there is proper path separator between prefix and file.

Signed-off-by: Jan Kiszka <[email protected]>
---
 utils.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/utils.c b/utils.c
index 324d77d..af0d739 100644
--- a/utils.c
+++ b/utils.c
@@ -211,7 +211,6 @@ EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE device,
 {
        UINTN prefixlen = 0;
        EFI_DEVICE_PATH *devpath = NULL;
-       CHAR16 *fullpath;
 
        LABELMODE lm = NOLABEL;
        /* Check if payload path contains a
@@ -258,25 +257,17 @@ EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE 
device,
                return FileDevicePath(device, payloadpath);
        }
 
-       CHAR16 *pathprefix = DevicePathToStr(devpath);
-       fullpath = AllocatePool(sizeof(CHAR16) *
-                          (StrLen(pathprefix) + StrLen(payloadpath) + 1));
-
-       StrCpy(fullpath, pathprefix);
-       StrCat(fullpath, payloadpath + prefixlen + 3);
-       INFO(L"Full path for kernel is: %s\n", fullpath);
-
-       FreePool(fullpath);
-       FreePool(pathprefix);
-
        EFI_DEVICE_PATH *filedevpath;
        EFI_DEVICE_PATH *appendeddevpath;
 
        filedevpath = FileDevicePath(NULL, payloadpath + prefixlen + 3);
        appendeddevpath = AppendDevicePath(devpath, filedevpath);
-
        FreePool(filedevpath);
 
+       CHAR16 *pathstr = DevicePathToStr(appendeddevpath);
+       INFO(L"Full path for kernel is: %s\n", pathstr);
+       FreePool(pathstr);
+
        return appendeddevpath;
 }
 
-- 
2.34.1


-- 
Siemens AG, Technology
Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/36c006a0-e2c3-a3be-f4cb-d1d8cfe5ca91%40siemens.com.

Reply via email to