|
|
00e791 |
From 79be2af5260b1f2e2a4680e74e14da0fdb42b570 Mon Sep 17 00:00:00 2001
|
|
|
00e791 |
From: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
00e791 |
Date: Fri, 7 Sep 2018 14:11:02 +0200
|
|
|
00e791 |
Subject: [PATCH 13/62] shim: Properly generate absolute paths from relative
|
|
|
00e791 |
image paths
|
|
|
00e791 |
|
|
|
00e791 |
The generate_path_from_image_path() doesn't properly handle the case when
|
|
|
00e791 |
shim is invoked using a relative path (e.g: from the EFI shell). In that
|
|
|
00e791 |
function, always the last component is stripped from absolute file path
|
|
|
00e791 |
to calculate the dirname, and this is concatenated with the image path.
|
|
|
00e791 |
|
|
|
00e791 |
But if the path is a relative one, the function will wrongly concatenate
|
|
|
00e791 |
the dirname with the relative image path, i.e:
|
|
|
00e791 |
|
|
|
00e791 |
Shell> FS0:
|
|
|
00e791 |
FS0:\> cd EFI
|
|
|
00e791 |
FS0:\EFI\> BOOT\BOOTX64.EFI
|
|
|
00e791 |
Failed to open \EFI\BOOT\BOOT\BOOTX64.EFI - Not found
|
|
|
00e791 |
Failed to load image \EFI\BOOT\BOOT\BOOTX64.EFI: Not found
|
|
|
00e791 |
start_image() returned Not found
|
|
|
00e791 |
|
|
|
00e791 |
Calculate the image path basename and concatenate that with the dirname.
|
|
|
00e791 |
|
|
|
00e791 |
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
00e791 |
Reviewed-by: Maran Wilson maran.wilson@oracle.com
|
|
|
00e791 |
Tested-by: Maran Wilson maran.wilson@oracle.com
|
|
|
00e791 |
Upstream-commit-id: a625fa5096c
|
|
|
00e791 |
---
|
|
|
00e791 |
shim.c | 6 ++++--
|
|
|
00e791 |
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
00e791 |
|
|
|
00e791 |
diff --git a/shim.c b/shim.c
|
|
|
00e791 |
index 05fc65005d1..5ab23d03db4 100644
|
|
|
00e791 |
--- a/shim.c
|
|
|
00e791 |
+++ b/shim.c
|
|
|
00e791 |
@@ -1610,9 +1610,11 @@ static EFI_STATUS generate_path_from_image_path(EFI_LOADED_IMAGE *li,
|
|
|
00e791 |
bootpath[j] = '\0';
|
|
|
00e791 |
}
|
|
|
00e791 |
|
|
|
00e791 |
- while (*ImagePath == '\\')
|
|
|
00e791 |
- ImagePath++;
|
|
|
00e791 |
+ for (i = 0, last = 0; i < StrLen(ImagePath); i++)
|
|
|
00e791 |
+ if (ImagePath[i] == '\\')
|
|
|
00e791 |
+ last = i + 1;
|
|
|
00e791 |
|
|
|
00e791 |
+ ImagePath = ImagePath + last;
|
|
|
00e791 |
*PathName = AllocatePool(StrSize(bootpath) + StrSize(ImagePath));
|
|
|
00e791 |
|
|
|
00e791 |
if (!*PathName) {
|
|
|
00e791 |
--
|
|
|
00e791 |
2.26.2
|
|
|
00e791 |
|