efi_loader: multi part device paths to text
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 18 Feb 2021 17:30:43 +0000 (18:30 +0100)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 21 Feb 2021 08:21:35 +0000 (09:21 +0100)
Our current implementation of
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL.ConvertDevicePathToText() truncates multi
part device paths after the first part. We should convert all parts.

Render device path instance ends as commas. This is not explicitly
described in the UEFI spec but mimics what EDK II does.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/efi_loader/efi_device_path_to_text.c

index 1aaa9f9..81b8ac2 100644 (file)
@@ -369,11 +369,18 @@ static uint16_t EFIAPI *efi_convert_device_path_to_text(
 
        if (!device_path)
                goto out;
-       while (device_path &&
-              str + MAX_NODE_LEN < buffer + MAX_PATH_LEN) {
-               *str++ = '/';
-               str = efi_convert_single_device_node_to_text(str, device_path);
-               device_path = efi_dp_next(device_path);
+       while (device_path && str + MAX_NODE_LEN < buffer + MAX_PATH_LEN) {
+               if (device_path->type == DEVICE_PATH_TYPE_END) {
+                       if (device_path->sub_type !=
+                           DEVICE_PATH_SUB_TYPE_INSTANCE_END)
+                               break;
+                       *str++ = ',';
+               } else {
+                       *str++ = '/';
+                       str = efi_convert_single_device_node_to_text(
+                                                       str, device_path);
+               }
+               *(u8 **)&device_path += device_path->length;
        }
 
        text = efi_str_to_u16(buffer);