summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javierm@redhat.com>2018-09-07 14:11:02 +0200
committerPeter Jones <pjones@redhat.com>2020-07-23 20:52:12 -0400
commit79be2af5260b1f2e2a4680e74e14da0fdb42b570 (patch)
tree11adf58f8e1f1c47669ed86f162a8d3470494d8d
parentc4e3516e303daa42b3381ddd889a90641717f720 (diff)
downloadefi-boot-shim-79be2af5260b1f2e2a4680e74e14da0fdb42b570.tar.gz
efi-boot-shim-79be2af5260b1f2e2a4680e74e14da0fdb42b570.zip
shim: Properly generate absolute paths from relative image paths
The generate_path_from_image_path() doesn't properly handle the case when shim is invoked using a relative path (e.g: from the EFI shell). In that function, always the last component is stripped from absolute file path to calculate the dirname, and this is concatenated with the image path. But if the path is a relative one, the function will wrongly concatenate the dirname with the relative image path, i.e: Shell> FS0: FS0:\> cd EFI FS0:\EFI\> BOOT\BOOTX64.EFI Failed to open \EFI\BOOT\BOOT\BOOTX64.EFI - Not found Failed to load image \EFI\BOOT\BOOT\BOOTX64.EFI: Not found start_image() returned Not found Calculate the image path basename and concatenate that with the dirname. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Maran Wilson maran.wilson@oracle.com Tested-by: Maran Wilson maran.wilson@oracle.com Upstream-commit-id: a625fa5096c
-rw-r--r--shim.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/shim.c b/shim.c
index 05fc6500..5ab23d03 100644
--- a/shim.c
+++ b/shim.c
@@ -1610,9 +1610,11 @@ static EFI_STATUS generate_path_from_image_path(EFI_LOADED_IMAGE *li,
bootpath[j] = '\0';
}
- while (*ImagePath == '\\')
- ImagePath++;
+ for (i = 0, last = 0; i < StrLen(ImagePath); i++)
+ if (ImagePath[i] == '\\')
+ last = i + 1;
+ ImagePath = ImagePath + last;
*PathName = AllocatePool(StrSize(bootpath) + StrSize(ImagePath));
if (!*PathName) {